/*
* Very simple menu on an OLED display (with 8 lines of text).
* Displays menu items from the array menu. Max. number of items is 7.
*
* This sketch uses the library "U8g2", "Bounce2" and uses 3 buttons (up/down/select).
*
*/
// #include <U8x8lib.h>
#include <U8g2lib.h>
// #include <Bounce2.h>
// byte button_pins[] = {9, 5, 6}; // button pins, 4,5 = up/down, 6 = select
// #define NUM/BUTT/ONS sizeof(button_pins)
// Bounce * buttons = new Bounce[NUMBUTTONS];
// U8X8_SSD1306_128X64_NONAME_HW_I2C display(U8X8_PIN_NONE);
// U8X8_SSD1306_128X64_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
U8X8_SSD1306_128X64_NONAME_HW_I2C display(U8X8_PIN_NONE);
// #define MENU_SIZE 3
// char *menu[MENU_SIZE] = { "Polymer", "Temp", "RPM" };
// #define POLY_MENU_SIZE 4
// char *polyMenu[POLY_MENU_SIZE] = { "PET", "ABS", "PLA", "CUSTOM" };
// int cursor=0;
void setup() {
Serial.begin(9600);
// // Make input & enable pull-up resistors on switch pins
// for (int i=0; i<NUMBUTTONS; i++) {
// buttons[i].attach( button_pins[i], INPUT_PULLUP); // setup the bounce instance for the current button
// buttons[i].interval(25); // interval in ms
// }
display.begin();
display.setPowerSave(0);
// display.setFont(u8x8_font_inb46_4x8_r);
// display.drawString(6,0,"o");
// display.setFont(u8x8_font_inb21_2x4_r);
// display.draw2x2String(6,0,"o");
// delay(1000);
// showMenu();
// display.setFont(u8x8_font_amstrad_cpc_extended_r);
// display.setInverseFont(1);
// display.drawString(2, 2, "Inverse");
// display.setInverseFont(0);
// display.drawString(2, 3, "Normal");
// delay(10000);
// display.clearDisplay();
display.setFont(u8x8_font_open_iconic_play_8x8);
display.drawGlyph(4,0, '@'+6);
display.setFont(u8x8_font_open_iconic_play_4x4);
display.setInverseFont(1);
display.drawGlyph(6,2, '@'+6);
display.setFont(u8x8_font_amstrad_cpc_extended_r);
display.setInverseFont(0);
display.drawString(7,5, " ");
display.drawString(7,6, " ");
// horizontal scroll to the left
display.sendF("caaaaaac", 0x027, 0, 0, 0, 7, 1, 20, 0x2f); // configure & start scroll
// sendF("caaaaac", 0x029, 0, 0, 0, 7, 1, 0x2f); // configure & start scroll
delay(8000);
display.sendF("c", 0x02e); // disable scroll
// delay(10000);
display.clearDisplay();
// display.drawString(0,0,"PolyForm");
// display.setFont(u8x8_font_pxplusibmcgathin_r);
// display.drawString(0,6,"PF.999");
// display.drawString(11,6,"V0.01");
}
void loop() {
for(int c=0; c<50; c++)
{
display.setFont(u8g2_font_cursor_tf);
display.draw2x2Glyph(1,0, '@'+c);
display.setFont(u8x8_font_pxplusibmcgathin_r);
display.setCursor(13, 0);
display.print(c);
display.print(" ");
// display.drawString(3,0,'A'+c);
delay(1000);
}
// // process button press:
// for (int i = 0; i<NUMBUTTONS; i++) {
// buttons[i].update(); // Update the Bounce instance
// if ( buttons[i].fell() ) { // If it fell
// if (i==2) { // select
// //display.clearLine(7);
// //display.setCursor(0,7);
// display.setCursor(0,cursor + 3);
// display.print(">>");
// //display.print(menu[cursor]);
// executeChoice(cursor);
// }
// else {
// // erase previous cursor:
// display.setCursor(0,cursor + 3);
// display.print(" ");
// if (i==0) { // up
// cursor++;
// if (cursor>(MENU_SIZE)) cursor=0;
// }
// else { // down
// cursor--;
// if (cursor<0) cursor=(MENU_SIZE);
// }
// // show cursor at new line:
// if (cursor != MENU_SIZE) {
// display.setCursor(0,cursor + 3);
// display.print('>');
// }
// }
// } // end if button fell...
// } // end for-loop of button check
}
// /**
// * Clear display and show the menu.
// */
// void showMenu() {
// cursor=MENU_SIZE;
// display.clearDisplay();
// //display.print('POLYFORMER V0.0.1');
// display.drawString(0,0,"PolyFormer V0.01");
// // show menu items:
// for (int i = 0; i<MENU_SIZE; i++) {
// display.drawString(2,i + 3,menu[i]);
// }
// //display.setCursor(0,3);
// //display.print('>');
// }
// /**
// * Execute the task which matches the chosen menu item.
// */
// void executeChoice(int choice) {
// switch(choice) {
// case 0 :
// Serial.print("Execute choice "); Serial.print(choice); Serial.print(" - "); Serial.println(menu[choice]);
// break;
// case 1 :
// Serial.print("Execute choice "); Serial.print(choice); Serial.print(" - "); Serial.println(menu[choice]);
// break;
// case 2 :
// Serial.print("Execute choice "); Serial.print(choice); Serial.print(" - "); Serial.println(menu[choice]);
// break;
// case 3 :
// Serial.print("Execute choice "); Serial.print(choice); Serial.print(" - "); Serial.println(menu[choice]);
// break;
// case 4 :
// Serial.print("Execute choice "); Serial.print(choice); Serial.print(" - "); Serial.println(menu[choice]);
// break;
// default :
// Serial.print("Execute choice "); Serial.print(choice); Serial.print(" - "); Serial.println(menu[choice]);
// break;
// }
// }