From d5d0345dfe6a5c0653224428cf4e6700717231ba Mon Sep 17 00:00:00 2001 From: Seth Samuel Date: Tue, 22 Oct 2024 23:13:44 +1300 Subject: [PATCH 1/2] hello world fixed --- blockBreaker.ino | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/blockBreaker.ino b/blockBreaker.ino index 93882bb..b71023b 100644 --- a/blockBreaker.ino +++ b/blockBreaker.ino @@ -5,16 +5,17 @@ //screen setup U8G2_SH1106_128X64_NONAME_F_4W_HW_SPI u8g2(U8G2_R2, 17, 20, 21); -uint8_t *buf; +//uint8_t *buf; char outString[99]; void setup() { //Screen setup - buf = (uint8_t *)malloc(u8g2.getBufferSize()); + /* buf = (uint8_t *)malloc(u8g2.getBufferSize()); u8g2.setBufferPtr(buf); u8g2.initDisplay(); u8g2.clearDisplay(); - u8g2.setPowerSave(0); + u8g2.setPowerSave(0); */ + u8g2.begin(); u8g2.setFont(u8g2_font_ncenB14_tr); u8g2.clearBuffer(); From baef14fe26909f53c11143a1acb59eda39085cdc Mon Sep 17 00:00:00 2001 From: Seth Samuel Date: Tue, 22 Oct 2024 23:44:56 +1300 Subject: [PATCH 2/2] added ADC control to hello world --- blockBreaker.ino | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/blockBreaker.ino b/blockBreaker.ino index b71023b..cbd2ecd 100644 --- a/blockBreaker.ino +++ b/blockBreaker.ino @@ -2,29 +2,30 @@ #include //for screen #include //for screen #include +#define ADC_PIN 26 -//screen setup +int adcVal = 0; +float xLocation = 0; + +//screen setup U8G2_SH1106_128X64_NONAME_F_4W_HW_SPI u8g2(U8G2_R2, 17, 20, 21); //uint8_t *buf; char outString[99]; void setup() { - //Screen setup - /* buf = (uint8_t *)malloc(u8g2.getBufferSize()); - u8g2.setBufferPtr(buf); - u8g2.initDisplay(); - u8g2.clearDisplay(); - u8g2.setPowerSave(0); */ + //setup screen u8g2.begin(); u8g2.setFont(u8g2_font_ncenB14_tr); - - u8g2.clearBuffer(); - sprintf(outString,"helloworld"); - u8g2.drawStr(7,35,outString); - u8g2.sendBuffer(); + //setup ADC + analogReadResolution(10); + digitalWriteFast(23, 1); } void loop() { - // put your main code here, to run repeatedly: - + adcVal = analogRead(ADC_PIN); + xLocation = (((float)adcVal/1024)*100); + u8g2.clearBuffer(); + sprintf(outString, "helloworld"); + u8g2.drawStr(xLocation, 35, outString); + u8g2.sendBuffer(); }