Skip to content

Commit 3257385

Browse files
committed
Changes from @Defragster for OLED
1 parent 6e29ad8 commit 3257385

File tree

2 files changed

+29
-11
lines changed

2 files changed

+29
-11
lines changed

hardware/digistump/avr/libraries/DigisparkOLED/DigisparkOLED.cpp

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@
1717

1818
#include "DigisparkOLED.h"
1919
#include "font6x8.h"
20-
#include "font8x16.h"
2120

21+
#ifndef _nofont_8x16 // tBUG Optional removal to save code space
22+
#include "font8x16.h"
23+
#endif
2224

2325

2426
// ----------------------------------------------------------------------------
@@ -153,18 +155,27 @@ size_t SSD1306Device::write(byte c) {
153155
if(c == '\r')
154156
return 1;
155157
if(c == '\n'){
156-
if(oledFont == 0)
157-
setCursor(0, oledY+1);
158-
else
159-
setCursor(0, oledY+2);
158+
if(oledFont == FONT6X8) { // tBUG
159+
oledY++;
160+
// if ( oledY > 7) // tBUG
161+
// oledY = 7;
162+
}
163+
else {
164+
oledY+=2; //tBUG Large Font up by two
165+
if ( oledY > 6) // tBUG
166+
oledY = 6;
167+
}
168+
setCursor(0, oledY);
160169
return 1;
161170
}
162171

163-
if(oledFont == 0){
172+
if(oledFont == FONT6X8){
164173
if (oledX > 122)
165174
{
166175
oledX = 0;
167176
oledY++;
177+
if ( oledY > 7) // tBUG
178+
oledY = 7;
168179
setCursor(oledX, oledY);
169180
}
170181

@@ -176,11 +187,15 @@ size_t SSD1306Device::write(byte c) {
176187
ssd1306_send_data_stop();
177188
setCursor(oledX+6, oledY);
178189
}
190+
#ifndef _nofont_8x16 // tBUG
179191
else{
180192
if (oledX > 120)
181193
{
182194
oledX = 0;
183-
oledY++;
195+
oledY+=2; //tBUG Large Font up by two
196+
// oledY++;
197+
if ( oledY > 6) // tBUG
198+
oledY = 6;
184199
setCursor(oledX, oledY);
185200
}
186201

@@ -198,8 +213,8 @@ size_t SSD1306Device::write(byte c) {
198213
}
199214
ssd1306_send_data_stop();
200215
setCursor(oledX + 8, oledY - 1);
201-
202216
}
217+
#endif
203218
return 1;
204219
}
205220

@@ -210,9 +225,9 @@ void SSD1306Device::bitmap(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, const
210225
{
211226
uint16_t j = 0;
212227
uint8_t y, x;
213-
if (y1 % 8 == 0) y = y1 / 8;
214-
else y = y1 / 8 + 1;
215-
for (y = y0; y < y1; y++)
228+
// if (y1 % 8 == 0) y = y1 / 8; // else y = y1 / 8 + 1; // tBUG :: this does nothing as y is initialized below
229+
// THIS PARAM rule on y makes any adjustment here WRONG //usage oled.bitmap(START X IN PIXELS, START Y IN ROWS OF 8 PIXELS, END X IN PIXELS, END Y IN ROWS OF 8 PIXELS, IMAGE ARRAY);
230+
for (y = y0; y < y1; y++)
216231
{
217232
setCursor(x0,y);
218233
ssd1306_send_data_start();

hardware/digistump/avr/libraries/DigisparkOLED/DigisparkOLED.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
#ifndef DIGISPARKOLED_H
1818
#define DIGISPARKOLED_H
1919

20+
// #define _nofont_8x16 //tBUG
21+
#ifndef _nofont_8x16 //tBUG
2022
#define FONT8X16 1
23+
#endif
2124
#define FONT6X8 0
2225

2326
// ----------------------------------------------------------------------------

0 commit comments

Comments
 (0)