108 #include "uStepper.h" 112 #include "SoftwareSerial.h" 140 static unsigned char fw_bits[] = {
141 0x41, 0x00, 0xc3, 0x00, 0xc7, 0x01, 0xcf, 0x03, 0xdf, 0x07, 0xcf, 0x03,
142 0xc7, 0x01, 0xc3, 0x00, 0x41, 0x00 };
143 static unsigned char bw_bits[] = {
144 0x10, 0x04, 0x18, 0x06, 0x1c, 0x07, 0x9e, 0x07, 0xdf, 0x07, 0x9e, 0x07,
145 0x1c, 0x07, 0x18, 0x06, 0x10, 0x04 };
148 static unsigned char rec_bits[] = {
149 0xfc, 0x00, 0xfe, 0x01, 0xff, 0x03, 0xff, 0x03, 0xff, 0x03, 0xff, 0x03,
150 0xff, 0x03, 0xff, 0x03, 0xfe, 0x01, 0xfc, 0x00 };
151 static unsigned char stop_bits[] = {
152 0xff, 0x03, 0xff, 0x03, 0xff, 0x03, 0xff, 0x03, 0xff, 0x03, 0xff, 0x03,
153 0xff, 0x03, 0xff, 0x03, 0xff, 0x03, 0xff, 0x03 };
154 static unsigned char pse_bits[] = {
155 0xcc, 0x00, 0xcc, 0x00, 0xcc, 0x00, 0xcc, 0x00, 0xcc, 0x00, 0xcc, 0x00,
156 0xcc, 0x00, 0xcc, 0x00, 0xcc, 0x00, 0xcc, 0x00 };
158 #define play_height 11 159 static unsigned char play_bits[] = {
160 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x1f, 0x0f, 0x07, 0x03, 0x01 };
161 #define loop_width 11 162 #define loop_height 10 163 static unsigned char loop_bits[] = {
164 0x04, 0x00, 0x08, 0x00, 0x9e, 0x03, 0x09, 0x04, 0x05, 0x04, 0x01, 0x05,
165 0x81, 0x04, 0xce, 0x03, 0x80, 0x00, 0x00, 0x01 };
166 #define logo_width 90 167 #define logo_height 16 168 static unsigned char logo_bits[] = {
169 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
170 0x00, 0x80, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
171 0x00, 0xc0, 0xff, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
172 0x00, 0xc0, 0xc7, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
173 0x3e, 0xcf, 0x07, 0xfc, 0xe3, 0xc3, 0x7b, 0x78, 0x0f, 0x3e, 0x9c, 0x01,
174 0xdf, 0xcf, 0x3f, 0xfe, 0xf3, 0xf7, 0xff, 0xfe, 0x1f, 0x7f, 0xff, 0x03,
175 0x3e, 0xcf, 0xff, 0x78, 0x38, 0xc7, 0xf3, 0x78, 0x9e, 0x73, 0xfe, 0x03,
176 0x3c, 0x8f, 0xff, 0x79, 0xfc, 0xcf, 0xf3, 0x79, 0xde, 0xff, 0xbc, 0x01,
177 0x1c, 0x47, 0xfe, 0x78, 0xfc, 0xcf, 0xf3, 0x78, 0xbe, 0x7f, 0x1e, 0x00,
178 0x3c, 0xef, 0xf0, 0x79, 0x38, 0xc0, 0xf3, 0x79, 0xde, 0x03, 0x1e, 0x00,
179 0xbe, 0xcf, 0xff, 0x78, 0x78, 0xc4, 0xf3, 0x78, 0x9e, 0x47, 0x3e, 0x00,
180 0xfc, 0xdf, 0x7f, 0xf8, 0xf3, 0xc7, 0x7f, 0xf8, 0x0f, 0x7f, 0x7e, 0x00,
181 0x38, 0x07, 0x3f, 0xf0, 0xe1, 0xc3, 0x3f, 0xf8, 0x07, 0x3e, 0x7f, 0x00,
182 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x7c, 0x00, 0x00, 0x00, 0x00,
183 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x07, 0xfc, 0x00, 0x00, 0x00, 0x00,
184 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x07, 0xf8, 0x00, 0x00, 0x00, 0x00 };
206 #define RESETWDT asm volatile("WDR \n\t") 209 extern "C" void WDT_vect(
void) __attribute__ ((signal,used));
272 U8G2_SSD1306_128X64_NONAME_1_4W_SW_SPI *
u8g2;
395 void idlePage(
bool pidMode,
float pos);
407 void recordPage(
bool pidMode,
bool recorded, uint8_t index,
float pos);
417 void playPage(
bool loopMode,
bool pidMode, uint8_t index,
bool mode);
427 void pausePage(
bool loopMode,
bool pidMode, uint8_t index);
440 friend void WDT_vect(
void) __attribute__ ((signal,used));
void loop(void)
Contains the main logic of the shield functionality, e.g. transition between states (idle...
void playPage(bool loopMode, bool pidMode, uint8_t index, bool mode)
Holds the code for the play page of the OLED.
Watchdog timer interrupt handler, for examining the buttons periodically.
void recordMode(void)
Holds the record logic, showing the record page and recording positions from user input...
uStepper stepper
Creates an uStepper instance.
void changeVelocity(bool speedDirection=1)
Holds the code for the changing velocity during sequence play.
void idleMode(void)
Holds the idle logic; page to show, what buttons to enable etc.
void debounce(buttons *btn, uint8_t sample)
This function handles the debouncing and tracking of whether buttons are pressed, released or held...
void resetAllButton()
Resets the state of all 4 buttons at once.
volatile buttons recordBtn
void recordPage(bool pidMode, bool recorded, uint8_t index, float pos)
Holds the code for the record page of the OLED.
void idlePage(bool pidMode, float pos)
Holds the code for the idle page of the OLED.
void timeMode(void)
Holds the timelapse logic, showing the timelapse page.
friend void WDT_vect(void) __attribute__((signal
U8G2_SSD1306_128X64_NONAME_1_4W_SW_SPI * u8g2
void playMode(void)
Holds the play logic, showing play page and running the recorded sequence.
void manBackward(void)
Holds the manual backward logic for driving the stepper motor manually with the pushbuttons.
void pauseMode(void)
Holds the pause logic, showing the pause page and pausing the playing of a sequence.
void resetButton(buttons *btn)
Function for resetting the state of a button seperately.
void inputs(void)
Reads the four buttons and writes their value; no push, short push or long push, to global variables...
SoftwareSerial * BTSerial
void startPage(void)
Holds the code for the start page of the OLED.
volatile buttons forwardBtn
void pausePage(bool loopMode, bool pidMode, uint8_t index)
Holds the code for the pause page of the OLED.
void WDT_vect(void) __attribute__((signal
void manForward(void)
Holds the manual forward logic for driving the stepper motor manually with the pushbuttons.
volatile buttons backwardsBtn
uint8_t buttonState(uint8_t button, uint8_t nmbr)
Returns the button state of the appropriate button.
egoShield(void)
Constructor of egoShield class.
void setup(uint16_t acc=1500, uint16_t vel=1000, uint8_t uStep=SIXTEEN, uint16_t fTol=10, uint16_t fHys=5, float P=1.0, float I=0.02, float D=0.006, float res=1)
Initializes buttons, OLED, uStepper and BT-module.