Created
March 26, 2019 16:52
-
-
Save baobao/80d9b4f59adabcc0e7ad86642d201f44 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <SPI.h> | |
#include <CubettoLibrary.h> | |
#include <AccelStepper.h> | |
#include <aci.h> | |
#include <KickstarterBackers.h> | |
Cubetto CubettoRobot; | |
/** ************************************************************************************************************************************ | |
* @function | |
* @brief | |
***************************************************************************************************************************************/ | |
void setup() { | |
SPI.begin(); | |
SPI.setBitOrder(LSBFIRST); | |
SPI.setDataMode(SPI_MODE0); | |
SPI.setClockDivider(SPI_CLOCK_DIV16); | |
CubettoRobot.begin(); // Setup Robot | |
CubettoRobot.startAdvertisingBluetooth(0, true); // Start Advertising and Auto | |
} | |
/** ************************************************************************************************************************************ | |
* @function | |
* @brief | |
***************************************************************************************************************************************/ | |
void loop() { | |
CubettoRobot.bluetoothTasks(); | |
if (CubettoRobot.checkForBluetoothMessage()==true) | |
{ | |
CubettoRobot.decodeInterfaceInstructions (CubettoRobot.bluetoothMessageCommand); | |
} | |
// Tasks to call every 1 second | |
oneSecondLoop (); | |
} | |
/** ************************************************************************************************************************************ | |
* @function | |
* @brief | |
***************************************************************************************************************************************/ | |
void oneSecondLoop (void) | |
{ | |
static uint32_t counter = 0; | |
counter++; | |
if (counter>0xFFFF) | |
{ | |
counter=0; | |
CubettoRobot.updateBatteryLevel(); | |
CubettoRobot.sendBatteryLevelToBluetooth(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment