68 u8g2 =
new U8G2_SSD1306_128X64_NONAME_1_4W_SW_SPI(U8G2_R0, 11, 9, U8X8_PIN_NONE, 2, 10);
71 void egoShield::setup(uint16_t acc, uint16_t vel, uint8_t uStep, uint16_t fTol, uint16_t fHys,
float P,
float I,
float D)
87 pinMode(RECBT ,INPUT);
89 digitalWrite(FWBT ,HIGH);
90 digitalWrite(PLBT ,HIGH);
91 digitalWrite(RECBT ,HIGH);
92 digitalWrite(BWBT ,HIGH);
222 stepper.setMaxAcceleration(1500);
315 if(digitalRead(button)==0)
317 while(digitalRead(button)==0 &&
longPushFlag[nmbr] == 0)
344 while(digitalRead(FWBT)==0)
361 while(digitalRead(BWBT)==0)
377 u8g2->drawXBM(19, 20, logo_width, logo_height, logo_bits);
378 }
while (
u8g2->nextPage() );
388 u8g2->drawBox(1, 1, 128, 12);
389 u8g2->drawBox(1, 48, 128, 68);
390 u8g2->setFontMode(0);
391 u8g2->setDrawColor(0);
392 u8g2->setFontDirection(0);
393 u8g2->setFont(u8g2_font_6x10_tf);
396 u8g2->drawXBM(5, 51, en_width, en_height, bw_bits);
397 u8g2->drawXBM(112, 51, en_width, en_height, fw_bits);
398 u8g2->drawXBM(32, 50, play_width, play_height, play_bits);
399 u8g2->drawXBM(43, 51, tt_width, tt_height, stop_bits);
400 u8g2->drawXBM(71, 51, tt_width, tt_height, rec_bits);
401 u8g2->drawXBM(85, 51, tt_width, tt_height, pse_bits);
404 u8g2->drawStr(2,10,
"Idle");
407 u8g2->drawStr(45,10,
"PID ON");
411 u8g2->drawStr(45,10,
"PID OFF");
413 u8g2->setFontMode(1);
414 u8g2->setDrawColor(1);
416 sBuf += (int32_t)pos;
418 sBuf.toCharArray(buf, 16);
419 u8g2->drawStr(2,35,buf);
420 }
while (
u8g2->nextPage() );
430 u8g2->drawBox(1, 1, 128, 12);
431 u8g2->drawBox(1, 48, 128, 68);
432 u8g2->setFontMode(0);
433 u8g2->setDrawColor(0);
434 u8g2->setFontDirection(0);
435 u8g2->setFont(u8g2_font_6x10_tf);
437 u8g2->drawXBM(5, 51, en_width, en_height, bw_bits);
438 u8g2->drawXBM(112, 51, en_width, en_height, fw_bits);
439 u8g2->drawXBM(38, 51, tt_width, tt_height, stop_bits);
440 u8g2->drawXBM(76, 51, tt_width, tt_height, rec_bits);
443 u8g2->drawStr(2,10,
"Record");
446 u8g2->drawStr(45,10,
"PID ON");
450 u8g2->drawStr(45,10,
"PID OFF");
452 u8g2->setFontMode(1);
453 u8g2->setDrawColor(1);
459 sBuf.toCharArray(buf, 22);
460 u8g2->drawStr(2,35,buf);
465 sBuf += (int32_t)pos;
467 sBuf.toCharArray(buf, 16);
468 u8g2->drawStr(2,35,buf);
470 }
while (
u8g2->nextPage() );
479 u8g2->drawBox(1, 1, 128, 12);
480 u8g2->drawBox(1, 48, 128, 68);
481 u8g2->setFontMode(0);
482 u8g2->setDrawColor(0);
483 u8g2->setFontDirection(0);
484 u8g2->setFont(u8g2_font_6x10_tf);
488 u8g2->drawXBM(110, 2, loop_width, loop_height, loop_bits);
492 u8g2->drawXBM(5, 51, en_width, en_height, bw_bits);
493 u8g2->drawXBM(112, 51, en_width, en_height, fw_bits);
494 u8g2->drawXBM(32, 50, play_width, play_height, play_bits);
495 u8g2->drawXBM(43, 51, tt_width, tt_height, stop_bits);
496 u8g2->drawXBM(77, 51, tt_width, tt_height, pse_bits);
499 u8g2->drawStr(2,10,
"Play");
502 u8g2->drawStr(45,10,
"PID ON");
506 u8g2->drawStr(45,10,
"PID OFF");
508 u8g2->setFontMode(1);
509 u8g2->setDrawColor(1);
510 u8g2->drawStr(2,35,
"Moving to pos");
511 String(index).toCharArray(buf, 3);
512 u8g2->drawStr(90,35,buf);
513 }
while (
u8g2->nextPage() );
522 u8g2->drawBox(1, 1, 128, 12);
523 u8g2->drawBox(1, 48, 128, 68);
524 u8g2->setFontMode(0);
525 u8g2->setDrawColor(0);
526 u8g2->setFontDirection(0);
527 u8g2->setFont(u8g2_font_6x10_tf);
531 u8g2->drawXBM(110, 2, loop_width, loop_height, loop_bits);
535 u8g2->drawXBM(32, 50, play_width, play_height, play_bits);
536 u8g2->drawXBM(43, 51, tt_width, tt_height, stop_bits);
539 u8g2->drawStr(2,10,
"Pause");
542 u8g2->drawStr(45,10,
"PID ON");
546 u8g2->drawStr(45,10,
"PID OFF");
548 u8g2->setFontMode(1);
549 u8g2->setDrawColor(1);
550 u8g2->drawStr(2,35,
"Paused at pos");
551 String(index).toCharArray(buf, 3);
552 u8g2->drawStr(90,35,buf);
553 }
while (
u8g2->nextPage() );
void loop(void)
Contains the main logic of the shield functionality, e.g. transition between states (idle...
void recordMode(void)
Holds the record logic, showing the record page and recording positions from user input...
uStepper stepper
Creates an uStepper instance.
void idleMode(void)
Holds the idle logic; page to show, what buttons to enable etc.
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)
Initializes buttons, OLED, uStepper and BT-module.
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.
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 pauseMode(void)
Holds the pause logic, showing the pause page and pausing the playing of a sequence.
Function prototypes and definitions for the egoShield library.
void fastForward(void)
Holds the fast forward logic for driving the stepper motor manually with the pushbuttons.
void inputs(void)
Reads the four buttons and writes their value; no push, short push or long push, to global variables...
void fastBackward(void)
Holds the fast backward logic for driving the stepper motor manually with the pushbuttons.
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.
uint8_t buttonState(uint8_t button, uint8_t nmbr)
Returns the button state of the appropriate button.
egoShield(void)
Constructor of egoShield class.
void playPage(bool loopMode, bool pidMode, uint8_t index)
Holds the code for the play page of the OLED.