LCDGFX LCD display driver  1.0.5
This library is developed to control SSD1306/SSD1325/SSD1327/SSD1331/SSD1351/IL9163/PCD8554 RGB i2c/spi LED displays
io.h
1 /*
2  MIT License
3 
4  Copyright (c) 2018-2019, Alexey Dynda
5 
6  Permission is hereby granted, free of charge, to any person obtaining a copy
7  of this software and associated documentation files (the "Software"), to deal
8  in the Software without restriction, including without limitation the rights
9  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  copies of the Software, and to permit persons to whom the Software is
11  furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in all
14  copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  SOFTWARE.
23 */
24 
25 /*
26  * @file lcd_hal/mingw/io.h SSD1306 MINGW IO communication functions
27  */
28 
29 #ifndef _SSD1306V2_MINGW_IO_H_
30 #define _SSD1306V2_MINGW_IO_H_
31 
32 // Use the same library interface as for Linux
33 #define CONFIG_LINUX_I2C_AVAILABLE
34 #define CONFIG_LINUX_SPI_AVAILABLE
35 
36 #if defined(SDL_EMULATION) // SDL Emulation mode includes
37 #include "sdl_core.h"
38 #endif
39 
40 #include <windows.h>
41 #include <stdint.h>
42 #include <unistd.h>
43 #include "sdl_core.h"
44 #include <time.h>
45 #include <string.h>
46 
48 #define PROGMEM
49 
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
53 
54 static inline char *utoa(unsigned int num, char *str, int radix)
55 {
56  char temp[17]; //an int can only be 16 bits long
57  //at radix 2 (binary) the string
58  //is at most 16 + 1 null long.
59  int temp_loc = 0;
60  int str_loc = 0;
61 
62  //construct a backward string of the number.
63  do {
64  int digit = (unsigned int)num % radix;
65  if (digit < 10)
66  temp[temp_loc++] = digit + '0';
67  else
68  temp[temp_loc++] = digit - 10 + 'A';
69  num = ((unsigned int)num) / radix;
70  } while ((unsigned int)num > 0);
71 
72  temp_loc--;
73 
74 
75  //now reverse the string.
76  while ( temp_loc >=0 ) {// while there are still chars
77  str[str_loc++] = temp[temp_loc--];
78  }
79  str[str_loc] = 0; // add null termination.
80 
81  return str;
82 }
83 
84 #ifdef __cplusplus
85 }
86 #endif
87 
88 #endif
89