Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "U8glib.h"
- U8GLIB_SH1106_128X64 u8g(13, 11, 10, 9);
- int cnt;
- void draw(void) {
- // graphic commands to redraw the complete screen should be placed here
- u8g.setFont(u8g_font_unifont);
- //u8g.setFont(u8g_font_osb21);
- u8g.drawStr( 0, 22, "Hello World!");
- }
- void setup(void) {
- // flip screen, if required
- // u8g.setRot180();
- // set SPI backup if required
- //u8g.setHardwareBackup(u8g_backup_avr_spi);
- // assign default color value
- if ( u8g.getMode() == U8G_MODE_R3G3B2 ) {
- u8g.setColorIndex(255); // white
- }
- else if ( u8g.getMode() == U8G_MODE_GRAY2BIT ) {
- u8g.setColorIndex(3); // max intensity
- }
- else if ( u8g.getMode() == U8G_MODE_BW ) {
- u8g.setColorIndex(1); // pixel on
- }
- else if ( u8g.getMode() == U8G_MODE_HICOLOR ) {
- u8g.setHiColorByRGB(255,255,255);
- }
- cnt = 3;
- }
- void loop(void) {
- // picture loop
- u8g.firstPage();
- do {
- draw();
- } while( u8g.nextPage() );
- // rebuild the picture after some delay
- delay(1000);
- switch(--cnt){
- case 2:
- u8g.setRot90();
- break;
- case 1:
- u8g.setRot180();
- break;
- case 0:
- u8g.setRot270();
- break;
- default:
- u8g.undoRotation();
- cnt = 3;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement