datacute / Tiny4kOLED

Library for an ATTiny85 to use an SSD1306 powered, double buffered, 128x32 pixel OLED, over I2C
MIT License
264 stars 39 forks source link

static uint8_t invertByte() method includes two unused parameters (yet I can't understand how these are not essential) #51

Closed SpenceKonde closed 1 year ago

SpenceKonde commented 1 year ago

These are very concerning to me - how could this method possibly work if the parameters aren't being used?!


C:\Users\Spence\Documents\Arduino\libraries\Tiny4kOLED\src\Tiny4kOLED.cpp: In function 'uint8_t invertByte(uint8_t, uint8_t, uint8_t)':
C:\Users\Spence\Documents\Arduino\libraries\Tiny4kOLED\src\Tiny4kOLED.cpp:132:35: warning: unused parameter 'x' [-Wunused-parameter]
 static uint8_t invertByte(uint8_t x, uint8_t y, uint8_t byte) {
                                   ^
C:\Users\Spence\Documents\Arduino\libraries\Tiny4kOLED\src\Tiny4kOLED.cpp:132:46: warning: unused parameter 'y' [-Wunused-parameter]
 static uint8_t invertByte(uint8_t x, uint8_t y, uint8_t byte) {
```                                              ^
datacute commented 1 year ago

This is one of the functions waiting for good documentation,

It is used as an implementation of a combining function, intercepting the graphical data being sent to the device, and able to alter the data.

It came about by my desire to display a large number 'behind' a graph, e.g. current temperature or current voltage behind a graph of the recent temperatures or voltages. To combine multiple data, I added setCombineFunction so I could specify a function that manipulated the data. I found that to be useful to me, the callback function needed to be passed the x and y coordinates of the data being sent. The combination of a graph and large number is generated by writing the text of the number, with a callback function that adds in the graph pixels (and adds padding).

Then, to save space, I altered the code that can invert the data being sent (using the invertOutput method), to be an implementation of that technique, hence the unusual signature.