int main(int argc, char **argv) { float soil = 65.5; float temp = 5.5; // I2C change parameters to fit to your LCD if ( !display.init(OLED_I2C_RESET,OLED_ADAFRUIT_I2C_128x64) ) exit(EXIT_FAILURE); display.begin(); // init done display.clearDisplay(); // clears the screen and buffer // text display tests display.setTextSize(1); display.setTextColor(WHITE); display.setCursor(0,0); display.print(" XBee Messung\n"); display.drawLine(0, 10, display.width()-1, 10, WHITE); display.setCursor(0,15); display.printf("Bodenfeuchte: %4.1f %%\n", soil); display.printf("Temperatur: %4.1f C\n\n\n", temp); if(soil > 50) { display.print("--> Feucht genug\n"); } else { display.print("--> Zu Trocken! \n"); } display.display(); // Free PI GPIO ports display.close(); }
int main() { int i, j; int black = 1; display.init(PIN_DC, PIN_RESET, PIN_CS, OLED_ADAFRUIT_SPI_128x32); display.begin(); /* 左上 */ display.drawPixel(0, 0, WHITE); display.display(); sleep(2); /* 左下 */ display.drawPixel(0, 31, WHITE); display.display(); sleep(2); /* 右上 */ display.drawPixel(127, 0, WHITE); display.display(); sleep(2); /* 右下 */ display.drawPixel(127, 31, WHITE); display.display(); sleep(2); for (i = 0; i < 32; i++) { for (j = 0; j < 128; j++) { //display.drawPixel(j, i, (black % 2) ? BLACK : WHITE); display.drawPixel(j, i, WHITE); display.display(); black++; } //black = i; //display.display(); } display.clearDisplay(); display.close(); return 0; }