Created
October 6, 2018 02:28
-
-
Save X3msnake/b781ad75a077994d3e30c26deff09dd3 to your computer and use it in GitHub Desktop.
testing nokia 5110 LCD screen with u8x8 library at altLab
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/) is Copyright of olikraus@gmail.com | |
// https://github.com/olikraus/u8g2/wiki/u8x8reference | |
#include <Arduino.h> | |
#include <U8x8lib.h> | |
#ifdef U8X8_HAVE_HW_SPI | |
#include <SPI.h> | |
#endif | |
U8X8_PCD8544_84X48_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display | |
int y = 0; | |
int x = 0; | |
void setup(void) | |
{ | |
u8x8.begin(); | |
u8x8.setPowerSave(0); | |
u8x8.setContrast(100); | |
} | |
void loop(void) | |
{ | |
u8x8.setFont(u8x8_font_amstrad_cpc_extended_r); | |
u8x8.setInverseFont(0); | |
u8x8.drawString(x,y,"altLab"); | |
u8x8.setInverseFont(1); | |
u8x8.drawString(x+2,y+1,"World"); | |
u8x8.setCursor(0, 4); | |
u8x8.print("X:"); | |
u8x8.setCursor(3, 4); | |
u8x8.print(x); | |
u8x8.setCursor(0, 5); | |
u8x8.print("Y:"); | |
u8x8.setCursor(3, 5); | |
u8x8.print(y); | |
x=x+1; | |
if(x>13){x=-13;y=y+1;} | |
if(y>5){y=0;} | |
delay(250); | |
u8x8.clear(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment