hmm... kann ich nicht erkennen, siehst du mehr als ich?
Hier ist der Testcode:
Code:
/*
*
*********** This code is for the ESP8266 ***********
*
****** ESP_ssd1306_128x64_I2C demo display *********
*
* using ESP_SSD1306 Adafruit library
* for a ssd1306 OLED Display with the ESP8266 board
*
*********** This code is for the ESP8266 ***********
*
*/
// I2C
#include <Wire.h> // Incl I2C comm, but needed for not getting compile error
#define ESPSDA D2 // defaults
#define ESPSCL D1 //
// TFT
#include <ESP_SSD1306.h> // Modification of Adafruit_SSD1306 for ESP8266 compatibility
#include <Adafruit_GFX.h> // Needs a little change in original Adafruit library (See README.txt file)
#include <Fonts/FreeSans12pt7b.h> //
#include <Fonts/FreeSansBold12pt7b.h> //
#include <Fonts/FreeSans9pt7b.h> //
#include <Fonts/FreeMono12pt7b.h> //
#include <Fonts/FreeMono9pt7b.h>
// Pin definitions
#define OLED_RESET 10 // GPIO10=D12 Pin RESET signal (virtual)
ESP_SSD1306 display(OLED_RESET); // FOR I2C
/*
#include <ButtonClass.h>
tButton btnup;
tButton btnle;
tButton btnri;
*/
//----------------------------------------------------------------------------
// OLED dashboard
//----------------------------------------------------------------------------
byte MAXMODE=12;
void dashboard(byte mode) {
if(mode>MAXMODE ) { mode=0; }
display.clearDisplay();
display.setFont();
display.display();
display.setFont();
}
//----------------------------------------------------------------------------
// menu list
//----------------------------------------------------------------------------
char LINELEN = 8;
char LINENUM = 4;
typedef struct {
char line[8][20] = {"line0_67 9012345678" ,"line1_6" ,"line2_67" ,
"line3_6789012345678" ,"line4_6789012345678" ,"line5_6789012345678" ,
"line6_6789012345678" ,"line7_6789012345678" };
char act=0, top=0, btm=top+LINENUM;
char subl[12]=" ";
} list;
list mList00;
void strcpysubl(char * dest, char * source, char pos) {
byte l;
memset(dest,' ',sizeof(dest));
dest[12]=0;
strncpy( dest+1, source+pos, LINELEN );
if(strlen(source)>(8+pos) ) dest[9] = '~' ;
else for( l=strlen(dest); l<=9; l++) dest[l]=' ';
dest[10] = '>';
dest[11] = 0;
}
void displayMenulist(list mList) {
int8_t start;
byte l;
if(mList.act>LINENUM) start=mList.act;
else start=0;
for(byte i=0+start; i<5+start; i++) {
strcpysubl( mList.subl, mList.line[i], 0);
if(i==mList.act) {
//display.setTextColor(BLACK, WHITE);
mList.subl[0]='>';
}
//else display.setTextColor(WHITE);
l=10 + i*13;
display.setCursor( 0, l); display.print(mList.subl);
Serial.println(mList.subl);
display.display();
}
}
void setup(void)
{
// Start Serial
Serial.begin(115200);
delay(2000); // wait for Serial()
// Start Wire (SDA, SCL)
Wire.begin(ESPSDA,ESPSCL); // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// SSD1306 Init
display.begin(SSD1306_SWITCHCAPVCC); // Switch OLED
display.setRotation(2);
display.clearDisplay(); // Clear the buffer.
// text display tests
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0,0);
display.println("Hello, world!");
display.display();
delay(1000);
display.clearDisplay();
display.display();
for(byte i=0; i<8; i++) { Serial.println(mList00.line[i]); }
Serial.print("act="); Serial.println((byte)mList00.act);
display.setFont(&FreeMono9pt7b); // h=13.10pt
displayMenulist(mList00);
delay(2000);
}
void loop() {
}
Lesezeichen