113 #include "uStepper.h" 117 #include "SoftwareSerial.h" 145 static unsigned char fw_bits[] = {
146 0x41, 0x00, 0xc3, 0x00, 0xc7, 0x01, 0xcf, 0x03, 0xdf, 0x07, 0xcf, 0x03,
147 0xc7, 0x01, 0xc3, 0x00, 0x41, 0x00 };
148 static unsigned char bw_bits[] = {
149 0x10, 0x04, 0x18, 0x06, 0x1c, 0x07, 0x9e, 0x07, 0xdf, 0x07, 0x9e, 0x07,
150 0x1c, 0x07, 0x18, 0x06, 0x10, 0x04 };
153 static unsigned char rec_bits[] = {
154 0xfc, 0x00, 0xfe, 0x01, 0xff, 0x03, 0xff, 0x03, 0xff, 0x03, 0xff, 0x03,
155 0xff, 0x03, 0xff, 0x03, 0xfe, 0x01, 0xfc, 0x00 };
156 static unsigned char stop_bits[] = {
157 0xff, 0x03, 0xff, 0x03, 0xff, 0x03, 0xff, 0x03, 0xff, 0x03, 0xff, 0x03,
158 0xff, 0x03, 0xff, 0x03, 0xff, 0x03, 0xff, 0x03 };
159 static unsigned char pse_bits[] = {
160 0xcc, 0x00, 0xcc, 0x00, 0xcc, 0x00, 0xcc, 0x00, 0xcc, 0x00, 0xcc, 0x00,
161 0xcc, 0x00, 0xcc, 0x00, 0xcc, 0x00, 0xcc, 0x00 };
163 #define play_height 11 164 static unsigned char play_bits[] = {
165 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x1f, 0x0f, 0x07, 0x03, 0x01 };
166 #define loop_width 11 167 #define loop_height 10 168 static unsigned char loop_bits[] = {
169 0x04, 0x00, 0x08, 0x00, 0x9e, 0x03, 0x09, 0x04, 0x05, 0x04, 0x01, 0x05,
170 0x81, 0x04, 0xce, 0x03, 0x80, 0x00, 0x00, 0x01 };
171 #define logo_width 90 172 #define logo_height 16 173 static unsigned char logo_bits[] = {
174 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
175 0x00, 0x80, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
176 0x00, 0xc0, 0xff, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
177 0x00, 0xc0, 0xc7, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
178 0x3e, 0xcf, 0x07, 0xfc, 0xe3, 0xc3, 0x7b, 0x78, 0x0f, 0x3e, 0x9c, 0x01,
179 0xdf, 0xcf, 0x3f, 0xfe, 0xf3, 0xf7, 0xff, 0xfe, 0x1f, 0x7f, 0xff, 0x03,
180 0x3e, 0xcf, 0xff, 0x78, 0x38, 0xc7, 0xf3, 0x78, 0x9e, 0x73, 0xfe, 0x03,
181 0x3c, 0x8f, 0xff, 0x79, 0xfc, 0xcf, 0xf3, 0x79, 0xde, 0xff, 0xbc, 0x01,
182 0x1c, 0x47, 0xfe, 0x78, 0xfc, 0xcf, 0xf3, 0x78, 0xbe, 0x7f, 0x1e, 0x00,
183 0x3c, 0xef, 0xf0, 0x79, 0x38, 0xc0, 0xf3, 0x79, 0xde, 0x03, 0x1e, 0x00,
184 0xbe, 0xcf, 0xff, 0x78, 0x78, 0xc4, 0xf3, 0x78, 0x9e, 0x47, 0x3e, 0x00,
185 0xfc, 0xdf, 0x7f, 0xf8, 0xf3, 0xc7, 0x7f, 0xf8, 0x0f, 0x7f, 0x7e, 0x00,
186 0x38, 0x07, 0x3f, 0xf0, 0xe1, 0xc3, 0x3f, 0xf8, 0x07, 0x3e, 0x7f, 0x00,
187 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x7c, 0x00, 0x00, 0x00, 0x00,
188 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x07, 0xfc, 0x00, 0x00, 0x00, 0x00,
189 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x07, 0xf8, 0x00, 0x00, 0x00, 0x00 };
210 #define RESETWDT asm volatile("WDR \n\t") 221 extern "C" void WDT_vect(
void) __attribute__ ((signal,used));
277 U8G2_SSD1306_128X64_NONAME_1_4W_SW_SPI *
u8g2;
329 volatile buttons forwardBtn = {0x1F, DEPRESSED, 0, 0, 0},
330 playBtn = {0x1F, DEPRESSED, 0, 0, 0},
331 recordBtn = {0x1F, DEPRESSED, 0, 0, 0},
332 backwardsBtn = {0x1F, DEPRESSED, 0, 0, 0};
398 void idlePage(
bool pidMode,
float pos);
410 void recordPage(
bool pidMode,
bool recorded, uint8_t index,
float pos);
420 void playPage(
bool loopMode,
bool pidMode, uint8_t index,
bool mode);
430 void pausePage(
bool loopMode,
bool pidMode, uint8_t index);
438 void timePage(uint8_t step,
bool pidMode);
451 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.
uStepper stepper
Creates an uStepper instance.
void WDT_vect(void) __attribute__((signal
Watchdog timer interrupt handler, for examining the buttons periodically.
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.
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
Watchdog timer interrupt handler, for examining the buttons periodically.
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 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, uint16_t shutterDelay=250)
Initializes buttons, OLED, uStepper and BT-module.
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.
void pausePage(bool loopMode, bool pidMode, uint8_t index)
Holds the code for the pause page of the OLED.
void changeVelocity(void)
Holds the code for the changing velocity during sequence play.
void manForward(void)
Holds the manual forward logic for driving the stepper motor manually with the pushbuttons.
void timePage(uint8_t step, bool pidMode)
Holds the code for the timelapse page of the OLED.
uint8_t buttonState(uint8_t button, uint8_t nmbr)
Returns the button state of the appropriate button.
egoShield(void)
Constructor of egoShield class.