DIY Logging Volt/Ampmeter
ssd1306.c
Go to the documentation of this file.
1 #include "ssd1306.h"
2 #include <math.h>
3 #include <stdlib.h>
4 #include <string.h> /* For memcpy */
5 
6 #include "stm32f1xx_ll_utils.h" /* LL_mDelay */
7 
8 // TODO Got code from https://github.com/afiskon/stm32-ssd1306
9 
10 #if defined(SSD1306_USE_I2C)
11 
14 
15 void ssd1306_Reset(void) {
16  /* For I2C - do nothing */
17 }
18 
19 void ssd1306_SelectDisplay(uint8_t display)
20 {
21  ssd1306Display = display;
22 
23  /* Left display selected */
24  if (display == 0) ssd1306Address = 0x78;
25 
26  /* Right display selected */
27  if (display == 1) ssd1306Address = 0x7A;
28 }
29 
30 /* Send a byte to the command register */
31 void ssd1306_WriteCommand(uint8_t byte) {
33 }
34 
35 /* Send data */
36 void ssd1306_WriteData(uint8_t* buffer, size_t buff_size) {
37  HAL_I2C_Mem_Write(&SSD1306_I2C_PORT, ssd1306Address, 0x40, 1, buffer, buff_size, HAL_MAX_DELAY);
38 }
39 
40 #elif defined(SSD1306_USE_SPI)
41 
42 void ssd1306_Reset(void) {
43  /* CS = High (not selected) */
45 
46  /* Reset the OLED */
48  LL_mDelay(10);
50  LL_mDelay(10);
51 }
52 
53 /* Send a byte to the command register */
54 void ssd1306_WriteCommand(uint8_t byte) {
57  HAL_SPI_Transmit(&SSD1306_SPI_PORT, (uint8_t *) &byte, 1, HAL_MAX_DELAY);
59 }
60 
61 /* Send data */
62 void ssd1306_WriteData(uint8_t* buffer, size_t buff_size) {
65  HAL_SPI_Transmit(&SSD1306_SPI_PORT, buffer, buff_size, HAL_MAX_DELAY);
67 }
68 
69 #else
70 #error "You should define SSD1306_USE_SPI or SSD1306_USE_I2C macro"
71 #endif
72 
73 
74 /* Screenbuffer */
77 
78 /* Screen object */
81 
82 /* Fills the Screenbuffer with values from a given buffer of a fixed length */
83 SSD1306_Error_t ssd1306_FillBuffer(uint8_t* buf, uint32_t len) {
85  if (len <= SSD1306_BUFFER_SIZE) {
86  if (ssd1306Display == 0) memcpy(SSD1306_BufferLeft,buf,len);
87  else if (ssd1306Display == 1) memcpy(SSD1306_BufferRight,buf,len);
88  ret = SSD1306_OK;
89  }
90  return (ret);
91 }
92 
93 /* Initialize the oled screen */
94 void ssd1306_Init(void) {
95  /* Reset OLED */
96  ssd1306_Reset();
97 
98  /* Wait for the screen to boot */
99  LL_mDelay(100);
100 
101  /* Init OLED */
102  ssd1306_SetDisplayOn(0); /* display off */
103 
104  ssd1306_WriteCommand(0x20); /* Set Memory Addressing Mode */
105  ssd1306_WriteCommand(0x00); /* 00b,Horizontal Addressing Mode; 01b,Vertical Addressing Mode; */
106  /* 10b,Page Addressing Mode (RESET); 11b,Invalid */
107 
108  ssd1306_WriteCommand(0xB0); /*Set Page Start Address for Page Addressing Mode,0-7 */
109 
110 #ifdef SSD1306_MIRROR_VERT
111  ssd1306_WriteCommand(0xC0); /* Mirror vertically */
112 #else
113  ssd1306_WriteCommand(0xC8); /* Set COM Output Scan Direction */
114 #endif
115 
116  ssd1306_WriteCommand(0x00); /* ---set low column address */
117  ssd1306_WriteCommand(0x10); /* ---set high column address */
118 
119  ssd1306_WriteCommand(0x40); /* --set start line address - CHECK */
120 
121  ssd1306_SetContrast(0xFF);
122 
123 #ifdef SSD1306_MIRROR_HORIZ
124  ssd1306_WriteCommand(0xA0); /* Mirror horizontally */
125 #else
126  ssd1306_WriteCommand(0xA1); /* --set segment re-map 0 to 127 - CHECK */
127 #endif
128 
129 #ifdef SSD1306_INVERSE_COLOR
130  ssd1306_WriteCommand(0xA7); /* --set inverse color */
131 #else
132  ssd1306_WriteCommand(0xA6); /* --set normal color */
133 #endif
134 
135 /* Set multiplex ratio. */
136 #if (SSD1306_HEIGHT == 128)
137  /* Found in the Luma Python lib for SH1106. */
138  ssd1306_WriteCommand(0xFF);
139 #else
140  ssd1306_WriteCommand(0xA8); /* --set multiplex ratio(1 to 64) - CHECK */
141 #endif
142 
143 #if (SSD1306_HEIGHT == 32)
144  ssd1306_WriteCommand(0x1F);
145 #elif (SSD1306_HEIGHT == 64)
146  ssd1306_WriteCommand(0x3F);
147 #elif (SSD1306_HEIGHT == 128)
148  ssd1306_WriteCommand(0x3F); /* Seems to work for 128px high displays too. */
149 #else
150 #error "Only 32, 64, or 128 lines of height are supported!"
151 #endif
152 
153  ssd1306_WriteCommand(0xA4); /* 0xa4,Output follows RAM content;0xa5,Output ignores RAM content */
154 
155  ssd1306_WriteCommand(0xD3); /* -set display offset - CHECK */
156  ssd1306_WriteCommand(0x00); /* -not offset */
157 
158  ssd1306_WriteCommand(0xD5); /* --set display clock divide ratio/oscillator frequency */
159  ssd1306_WriteCommand(0xF0); /* --set divide ratio */
160 
161  ssd1306_WriteCommand(0xD9); /* --set pre-charge period */
162  ssd1306_WriteCommand(0x22);
163 
164  ssd1306_WriteCommand(0xDA); /* --set com pins hardware configuration - CHECK */
165 #if (SSD1306_HEIGHT == 32)
166  ssd1306_WriteCommand(0x02);
167 #elif (SSD1306_HEIGHT == 64)
168  ssd1306_WriteCommand(0x12);
169 #elif (SSD1306_HEIGHT == 128)
170  ssd1306_WriteCommand(0x12);
171 #else
172 #error "Only 32, 64, or 128 lines of height are supported!"
173 #endif
174 
175  ssd1306_WriteCommand(0xDB); /* --set vcomh */
176  ssd1306_WriteCommand(0x20); /* 0x20,0.77xVcc */
177 
178  ssd1306_WriteCommand(0x8D); /* --set DC-DC enable */
179  ssd1306_WriteCommand(0x14);
180  ssd1306_SetDisplayOn(1); /* --turn on SSD1306 panel */
181 
182  /* Clear screen */
184 
185  /* Flush buffer to screen */
187 
188  /* Set default values for screen object */
189  if (ssd1306Display == 0) SSD1306Left.CurrentX = 0;
190  else if (ssd1306Display == 1) SSD1306Right.CurrentX = 0;
191  if (ssd1306Display == 0) SSD1306Left.CurrentY = 0;
192  else if (ssd1306Display == 1) SSD1306Right.CurrentY = 0;
193 
194  if (ssd1306Display == 0) SSD1306Left.Initialized = 1;
195  else if (ssd1306Display == 1) SSD1306Right.Initialized = 1;
196 }
197 
198 /* Fill the whole screen with the given color */
200  /* Set memory */
201  uint32_t i;
202 
203  if (ssd1306Display == 0)
204  {
205  for(i = 0; i < sizeof(SSD1306_BufferLeft); i++) {
206  SSD1306_BufferLeft[i] = (color == Black) ? 0x00 : 0xFF;
207  }
208  }
209  else if (ssd1306Display == 1)
210  {
211  for(i = 0; i < sizeof(SSD1306_BufferRight); i++) {
212  SSD1306_BufferRight[i] = (color == Black) ? 0x00 : 0xFF;
213  }
214  }
215 
216 
217 }
218 
219 /* Write the screenbuffer with changed to the screen */
221  /* Write data to each page of RAM. Number of pages
222  * depends on the screen height:
223  * - 32px == 4 pages
224  * - 64px == 8 pages
225  * - 128px == 16 pages */
226  for(uint8_t i = 0; i < SSD1306_HEIGHT/8; i++) {
227  ssd1306_WriteCommand(0xB0 + i); /* Set the current RAM page address. */
228  ssd1306_WriteCommand(0x00);
229  ssd1306_WriteCommand(0x10);
232  }
233 }
234 
235 /* Draw one pixel in the screenbuffer
236  * X => X Coordinate
237  * Y => Y Coordinate
238  * color => Pixel color */
239 void ssd1306_DrawPixel(uint8_t x, uint8_t y, SSD1306_COLOR color) {
240  if(x >= SSD1306_WIDTH || y >= SSD1306_HEIGHT) {
241  /* Don't write outside the buffer */
242  return;
243  }
244 
245  /* Check if pixel should be inverted */
246  if (ssd1306Display == 0)
247  {
248  if(SSD1306Left.Inverted) {
249  color = (SSD1306_COLOR)!color;
250  }
251  }
252  else if (ssd1306Display == 1)
253  {
254  if(SSD1306Right.Inverted) {
255  color = (SSD1306_COLOR)!color;
256  }
257  }
258 
259 
260  /* Draw in the right color */
261  if(color == White) {
262  if (ssd1306Display == 0) SSD1306_BufferLeft[x + (y / 8) * SSD1306_WIDTH] |= 1 << (y % 8);
263  else if (ssd1306Display == 1) SSD1306_BufferRight[x + (y / 8) * SSD1306_WIDTH] |= 1 << (y % 8);
264  } else {
265  if (ssd1306Display == 0) SSD1306_BufferLeft[x + (y / 8) * SSD1306_WIDTH] &= ~(1 << (y % 8));
266  else if (ssd1306Display == 1) SSD1306_BufferRight[x + (y / 8) * SSD1306_WIDTH] &= ~(1 << (y % 8));
267  }
268 }
269 
270 /* Draw 1 char to the screen buffer
271  * ch => char to write
272  * Font => Font to write with
273  * color => Black or White */
274 char ssd1306_WriteChar(char ch, FontDef Font, SSD1306_COLOR color) {
275  uint32_t i;
276  uint32_t b;
277  uint32_t j;
278 
279  /* Check if character is valid */
280  if (ch < 32 || ch > 126)
281  return (0);
282 
283  /* Check remaining space on current line */
284  if (ssd1306Display == 0)
285  {
286  if (SSD1306_WIDTH < (SSD1306Left.CurrentX + Font.FontWidth) ||
288  {
289  /* Not enough space on current line */
290  return (0);
291  }
292  }
293  else if (ssd1306Display == 1)
294  {
295  if (SSD1306_WIDTH < (SSD1306Right.CurrentX + Font.FontWidth) ||
297  {
298  /* Not enough space on current line */
299  return (0);
300  }
301  }
302 
303 
304  /* Use the font to write */
305  for(i = 0; i < Font.FontHeight; i++) {
306  b = Font.data[(ch - 32) * Font.FontHeight + i];
307  for(j = 0; j < Font.FontWidth; j++) {
308  if((b << j) & 0x8000) {
311  } else {
314  }
315  }
316  }
317 
318  /* The current space is now taken */
319  if (ssd1306Display == 0) SSD1306Left.CurrentX += Font.FontWidth;
320  else if (ssd1306Display == 1) SSD1306Right.CurrentX += Font.FontWidth;
321 
322  /* Return written char for validation */
323  return (ch);
324 }
325 
326 /* Write full string to screenbuffer */
327 char ssd1306_WriteString(char* str, FontDef Font, SSD1306_COLOR color) {
328  /* Write until null-byte */
329  while (*str) {
330  if (ssd1306_WriteChar(*str, Font, color) != *str) {
331  /* Char could not be written */
332  return (*str);
333  }
334 
335  /* Next char */
336  str++;
337  }
338 
339  /* Everything ok */
340  return (*str);
341 }
342 
343 /* Position the cursor */
344 void ssd1306_SetCursor(uint8_t x, uint8_t y) {
345  if (ssd1306Display == 0)
346  {
347  SSD1306Left.CurrentX = x;
348  SSD1306Left.CurrentY = y;
349  }
350  else if (ssd1306Display == 1)
351  {
354  }
355 }
356 
357 /* Draw line by Bresenhem's algorithm */
358 void ssd1306_Line(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2, SSD1306_COLOR color) {
359  int32_t deltaX = abs(x2 - x1);
360  int32_t deltaY = abs(y2 - y1);
361  int32_t signX = ((x1 < x2) ? 1 : -1);
362  int32_t signY = ((y1 < y2) ? 1 : -1);
363  int32_t error = deltaX - deltaY;
364  int32_t error2;
365 
366  ssd1306_DrawPixel(x2, y2, color);
367  while((x1 != x2) || (y1 != y2))
368  {
369  ssd1306_DrawPixel(x1, y1, color);
370  error2 = error * 2;
371  if(error2 > -deltaY)
372  {
373  error -= deltaY;
374  x1 += signX;
375  }
376  else
377  {
378  /* nothing to do */
379  }
380 
381  if(error2 < deltaX)
382  {
383  error += deltaX;
384  y1 += signY;
385  }
386  else
387  {
388  /* nothing to do */
389  }
390  }
391  return;
392 }
393 /* Draw polyline */
394 void ssd1306_Polyline(const SSD1306_VERTEX *par_vertex, uint16_t par_size, SSD1306_COLOR color) {
395  uint16_t i;
396  if(par_vertex != 0){
397  for(i = 1; i < par_size; i++){
398  ssd1306_Line(par_vertex[i - 1].x, par_vertex[i - 1].y, par_vertex[i].x, par_vertex[i].y, color);
399  }
400  }
401  else
402  {
403  /* nothing to do */
404  }
405  return;
406 }
407 /* Convert Degrees to Radians */
408 static float ssd1306_DegToRad(float par_deg) {
409  return (par_deg * 3.14 / 180.0);
410 }
411 /* Normalize degree to [0;360] */
412 static uint16_t ssd1306_NormalizeTo0_360(uint16_t par_deg) {
413  uint16_t loc_angle;
414  if(par_deg <= 360)
415  {
416  loc_angle = par_deg;
417  }
418  else
419  {
420  loc_angle = par_deg % 360;
421  loc_angle = ((par_deg != 0)?par_deg:360);
422  }
423  return (loc_angle);
424 }
425 /* DrawArc. Draw angle is beginning from 4 quart of trigonometric circle (3pi/2)
426  * start_angle in degree
427  * sweep in degree
428  */
429 void ssd1306_DrawArc(uint8_t x, uint8_t y, uint8_t radius, uint16_t start_angle, uint16_t sweep, SSD1306_COLOR color) {
430  #define CIRCLE_APPROXIMATION_SEGMENTS 36
431  float approx_degree;
432  uint32_t approx_segments;
433  uint8_t xp1;
434  uint8_t xp2;
435  uint8_t yp1;
436  uint8_t yp2;
437  uint32_t count = 0;
438  uint32_t loc_sweep = 0;
439  float rad;
440 
441  loc_sweep = ssd1306_NormalizeTo0_360(sweep);
442 
443  count = (ssd1306_NormalizeTo0_360(start_angle) * CIRCLE_APPROXIMATION_SEGMENTS) / 360;
444  approx_segments = (loc_sweep * CIRCLE_APPROXIMATION_SEGMENTS) / 360;
445  approx_degree = loc_sweep / (float)approx_segments;
446  while(count < approx_segments)
447  {
448  rad = ssd1306_DegToRad(count*approx_degree);
449  xp1 = x + (int8_t)(sin(rad)*radius);
450  yp1 = y + (int8_t)(cos(rad)*radius);
451  count++;
452  if(count != approx_segments)
453  {
454  rad = ssd1306_DegToRad(count*approx_degree);
455  }
456  else
457  {
458  rad = ssd1306_DegToRad(loc_sweep);
459  }
460  xp2 = x + (int8_t)(sin(rad)*radius);
461  yp2 = y + (int8_t)(cos(rad)*radius);
462  ssd1306_Line(xp1,yp1,xp2,yp2,color);
463  }
464 
465  return;
466 }
467 /* Draw circle by Bresenhem's algorithm */
468 void ssd1306_DrawCircle(uint8_t par_x,uint8_t par_y,uint8_t par_r,SSD1306_COLOR par_color) {
469  int32_t x = -par_r;
470  int32_t y = 0;
471  int32_t err = 2 - 2 * par_r;
472  int32_t e2;
473 
474  if (par_x >= SSD1306_WIDTH || par_y >= SSD1306_HEIGHT) {
475  return;
476  }
477 
478  do {
479  ssd1306_DrawPixel(par_x - x, par_y + y, par_color);
480  ssd1306_DrawPixel(par_x + x, par_y + y, par_color);
481  ssd1306_DrawPixel(par_x + x, par_y - y, par_color);
482  ssd1306_DrawPixel(par_x - x, par_y - y, par_color);
483  e2 = err;
484  if (e2 <= y) {
485  y++;
486  err = err + (y * 2 + 1);
487  if(-x == y && e2 <= x) {
488  e2 = 0;
489  }
490  else
491  {
492  /* nothing to do */
493  }
494  }
495  else
496  {
497  /* nothing to do */
498  }
499  if(e2 > x) {
500  x++;
501  err = err + (x * 2 + 1);
502  }
503  else
504  {
505  /* nothing to do */
506  }
507  } while(x <= 0);
508 
509  return;
510 }
511 
512 /* Draw rectangle */
513 void ssd1306_DrawRectangle(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2, SSD1306_COLOR color) {
514  ssd1306_Line(x1,y1,x2,y1,color);
515  ssd1306_Line(x2,y1,x2,y2,color);
516  ssd1306_Line(x2,y2,x1,y2,color);
517  ssd1306_Line(x1,y2,x1,y1,color);
518 
519  return;
520 }
521 
522 void ssd1306_SetContrast(const uint8_t value) {
523  const uint8_t kSetContrastControlRegister = 0x81;
524  ssd1306_WriteCommand(kSetContrastControlRegister);
525  ssd1306_WriteCommand(value);
526 }
527 
528 void ssd1306_SetDisplayOn(const uint8_t on) {
529  uint8_t value;
530  if (on) {
531  value = 0xAF; /* Display on */
532  if (ssd1306Display == 0) SSD1306Left.DisplayOn = 1;
533  else if (ssd1306Display == 1) SSD1306Right.DisplayOn = 1;
534  } else {
535  value = 0xAE; /* Display off */
536  if (ssd1306Display == 0) SSD1306Left.DisplayOn = 0;
537  else if (ssd1306Display == 1) SSD1306Right.DisplayOn = 0;
538  }
539  ssd1306_WriteCommand(value);
540 }
541 
543  if (ssd1306Display == 0) return (SSD1306Left.DisplayOn);
544  else if (ssd1306Display == 1) return (SSD1306Right.DisplayOn);
545  return (0);
546 }
ssd1306Display
uint8_t ssd1306Display
Definition: ssd1306.c:13
ssd1306Address
uint8_t ssd1306Address
Definition: ssd1306.c:12
SSD1306_CS_Pin
#define SSD1306_CS_Pin
Definition: ssd1306.h:63
SSD1306_Reset_Pin
#define SSD1306_Reset_Pin
Definition: ssd1306.h:77
SSD1306Right
static SSD1306_t SSD1306Right
Definition: ssd1306.c:80
ssd1306_SetCursor
void ssd1306_SetCursor(uint8_t x, uint8_t y)
Definition: ssd1306.c:344
SSD1306_COLOR
SSD1306_COLOR
Definition: ssd1306.h:105
ssd1306_DrawArc
void ssd1306_DrawArc(uint8_t x, uint8_t y, uint8_t radius, uint16_t start_angle, uint16_t sweep, SSD1306_COLOR color)
Definition: ssd1306.c:429
Black
@ Black
Definition: ssd1306.h:106
ssd1306_WriteString
char ssd1306_WriteString(char *str, FontDef Font, SSD1306_COLOR color)
Definition: ssd1306.c:327
FontDef
Definition: ssd1306_fonts.h:8
ssd1306_Polyline
void ssd1306_Polyline(const SSD1306_VERTEX *par_vertex, uint16_t par_size, SSD1306_COLOR color)
Definition: ssd1306.c:394
GPIO_PIN_SET
@ GPIO_PIN_SET
Definition: stm32f1xx_hal_gpio.h:68
ssd1306_DrawCircle
void ssd1306_DrawCircle(uint8_t par_x, uint8_t par_y, uint8_t par_r, SSD1306_COLOR par_color)
Definition: ssd1306.c:468
stm32f1xx_ll_utils.h
Header file of UTILS LL module.
ssd1306_UpdateScreen
void ssd1306_UpdateScreen(void)
Definition: ssd1306.c:220
ssd1306_WriteData
void ssd1306_WriteData(uint8_t *buffer, size_t buff_size)
Definition: ssd1306.c:36
ssd1306_SelectDisplay
void ssd1306_SelectDisplay(uint8_t display)
Definition: ssd1306.c:19
SSD1306_Reset_Port
#define SSD1306_Reset_Port
Definition: ssd1306.h:74
SSD1306_DC_Pin
#define SSD1306_DC_Pin
Definition: ssd1306.h:70
SSD1306_DC_Port
#define SSD1306_DC_Port
Definition: ssd1306.h:67
HAL_I2C_Mem_Write
HAL_StatusTypeDef HAL_I2C_Mem_Write(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size, uint32_t Timeout)
SSD1306_t::CurrentY
uint16_t CurrentY
Definition: ssd1306.h:118
SSD1306_CS_Port
#define SSD1306_CS_Port
Definition: ssd1306.h:60
ssd1306_FillBuffer
SSD1306_Error_t ssd1306_FillBuffer(uint8_t *buf, uint32_t len)
Definition: ssd1306.c:83
LL_mDelay
void LL_mDelay(uint32_t Delay)
This function provides accurate delay (in milliseconds) based on SysTick counter flag.
Definition: stm32f1xx_ll_utils.c:182
ssd1306_DrawRectangle
void ssd1306_DrawRectangle(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2, SSD1306_COLOR color)
Definition: ssd1306.c:513
ssd1306.h
SSD1306_VERTEX
Definition: ssd1306.h:123
SSD1306_t
Definition: ssd1306.h:116
SSD1306_t::Initialized
uint8_t Initialized
Definition: ssd1306.h:120
SSD1306_Error_t
SSD1306_Error_t
Definition: ssd1306.h:110
CIRCLE_APPROXIMATION_SEGMENTS
#define CIRCLE_APPROXIMATION_SEGMENTS
SSD1306_SPI_PORT
#define SSD1306_SPI_PORT
Definition: ssd1306.h:56
SSD1306_BufferLeft
static uint8_t SSD1306_BufferLeft[130 *64/8]
Definition: ssd1306.c:75
SSD1306_t::Inverted
uint8_t Inverted
Definition: ssd1306.h:119
ssd1306_SetContrast
void ssd1306_SetContrast(const uint8_t value)
Sets the contrast of the display.
Definition: ssd1306.c:522
ssd1306_WriteChar
char ssd1306_WriteChar(char ch, FontDef Font, SSD1306_COLOR color)
Definition: ssd1306.c:274
SSD1306_I2C_PORT
#define SSD1306_I2C_PORT
Definition: ssd1306_conf.h:24
FontDef::FontWidth
const uint8_t FontWidth
Definition: ssd1306_fonts.h:9
SSD1306_BUFFER_SIZE
#define SSD1306_BUFFER_SIZE
Definition: ssd1306.h:101
FontDef::data
const uint16_t * data
Definition: ssd1306_fonts.h:11
GPIO_PIN_RESET
@ GPIO_PIN_RESET
Definition: stm32f1xx_hal_gpio.h:67
SSD1306_ERR
@ SSD1306_ERR
Definition: ssd1306.h:112
ssd1306_Init
void ssd1306_Init(void)
Definition: ssd1306.c:94
FontDef::FontHeight
uint8_t FontHeight
Definition: ssd1306_fonts.h:10
SSD1306_BufferRight
static uint8_t SSD1306_BufferRight[130 *64/8]
Definition: ssd1306.c:76
SSD1306_t::CurrentX
uint16_t CurrentX
Definition: ssd1306.h:117
ssd1306_WriteCommand
void ssd1306_WriteCommand(uint8_t byte)
Definition: ssd1306.c:31
ssd1306_Reset
void ssd1306_Reset(void)
Definition: ssd1306.c:15
ssd1306_DegToRad
static float ssd1306_DegToRad(float par_deg)
Definition: ssd1306.c:408
SSD1306_OK
@ SSD1306_OK
Definition: ssd1306.h:111
HAL_MAX_DELAY
#define HAL_MAX_DELAY
Definition: stm32f1xx_hal_def.h:57
ssd1306_GetDisplayOn
uint8_t ssd1306_GetDisplayOn()
Reads DisplayOn state.
Definition: ssd1306.c:542
SSD1306_t::DisplayOn
uint8_t DisplayOn
Definition: ssd1306.h:121
SSD1306Left
static SSD1306_t SSD1306Left
Definition: ssd1306.c:79
SSD1306_HEIGHT
#define SSD1306_HEIGHT
Definition: ssd1306.h:92
ssd1306_Line
void ssd1306_Line(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2, SSD1306_COLOR color)
Definition: ssd1306.c:358
ssd1306_DrawPixel
void ssd1306_DrawPixel(uint8_t x, uint8_t y, SSD1306_COLOR color)
Definition: ssd1306.c:239
White
@ White
Definition: ssd1306.h:107
SSD1306_WIDTH
#define SSD1306_WIDTH
Definition: ssd1306_conf.h:52
ssd1306_NormalizeTo0_360
static uint16_t ssd1306_NormalizeTo0_360(uint16_t par_deg)
Definition: ssd1306.c:412
ssd1306_Fill
void ssd1306_Fill(SSD1306_COLOR color)
Definition: ssd1306.c:199
HAL_GPIO_WritePin
void HAL_GPIO_WritePin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin, GPIO_PinState PinState)
ssd1306_SetDisplayOn
void ssd1306_SetDisplayOn(const uint8_t on)
Set Display ON/OFF.
Definition: ssd1306.c:528