OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 Gurjant Kalsi <me@gurjantkalsi.com> | 2 * Copyright (c) 2015 Gurjant Kalsi <me@gurjantkalsi.com> |
3 * | 3 * |
4 * Permission is hereby granted, free of charge, to any person obtaining | 4 * Permission is hereby granted, free of charge, to any person obtaining |
5 * a copy of this software and associated documentation files | 5 * a copy of this software and associated documentation files |
6 * (the "Software"), to deal in the Software without restriction, | 6 * (the "Software"), to deal in the Software without restriction, |
7 * including without limitation the rights to use, copy, modify, merge, | 7 * including without limitation the rights to use, copy, modify, merge, |
8 * publish, distribute, sublicense, and/or sell copies of the Software, | 8 * publish, distribute, sublicense, and/or sell copies of the Software, |
9 * and to permit persons to whom the Software is furnished to do so, | 9 * and to permit persons to whom the Software is furnished to do so, |
10 * subject to the following conditions: | 10 * subject to the following conditions: |
(...skipping 15 matching lines...) Expand all Loading... |
26 #include <string.h> | 26 #include <string.h> |
27 | 27 |
28 #define SET_BIT(BUF, BITNUM) ((BUF)[(BITNUM) >> 3] |= (0xff & (0x1 << ((BITNUM)
& 0x07)))) | 28 #define SET_BIT(BUF, BITNUM) ((BUF)[(BITNUM) >> 3] |= (0xff & (0x1 << ((BITNUM)
& 0x07)))) |
29 | 29 |
30 uint8_t lcd_get_line(uint8_t *framebuffer, uint8_t idx, uint8_t *result) | 30 uint8_t lcd_get_line(uint8_t *framebuffer, uint8_t idx, uint8_t *result) |
31 { | 31 { |
32 framebuffer += FB_STRIDE * idx; | 32 framebuffer += FB_STRIDE * idx; |
33 | 33 |
34 memset(result, 0, MLCD_BYTES_LINE); | 34 memset(result, 0, MLCD_BYTES_LINE); |
35 | 35 |
| 36 #if FB_FORMAT == DISPLAY_FORMAT_RGB_332 |
36 for (int i = 0; i < MLCD_WIDTH; ++i) { | 37 for (int i = 0; i < MLCD_WIDTH; ++i) { |
37 uint8_t inpix = framebuffer[i]; | 38 uint8_t inpix = framebuffer[i]; |
38 | 39 |
39 int j = i * 3; | 40 int j = i * 3; |
40 | 41 |
41 if (inpix & 0x80) { | 42 if (inpix & 0x80) { |
42 SET_BIT(result, j); | 43 SET_BIT(result, j); |
43 } | 44 } |
44 if (inpix & 0x10) { | 45 if (inpix & 0x10) { |
45 SET_BIT(result, j + 1); | 46 SET_BIT(result, j + 1); |
46 } | 47 } |
47 if (inpix & 0x02) { | 48 if (inpix & 0x02) { |
48 SET_BIT(result, j + 2); | 49 SET_BIT(result, j + 2); |
49 } | 50 } |
| 51 } |
| 52 #elif FB_FORMAT == DISPLAY_FORMAT_RGB_x111 |
| 53 for (int i = 0; i < FB_STRIDE; ++i) { |
| 54 uint8_t val = framebuffer[i]; |
| 55 uint8_t inpix; |
50 | 56 |
| 57 int j = i * 6; |
| 58 |
| 59 inpix = val & 0xf; |
| 60 if (inpix & 0x4) { |
| 61 SET_BIT(result, j); |
| 62 } |
| 63 if (inpix & 0x2) { |
| 64 SET_BIT(result, j + 1); |
| 65 } |
| 66 if (inpix & 0x1) { |
| 67 SET_BIT(result, j + 2); |
| 68 } |
| 69 |
| 70 inpix = val >> 4; |
| 71 if (inpix & 0x4) { |
| 72 SET_BIT(result, j + 3); |
| 73 } |
| 74 if (inpix & 0x2) { |
| 75 SET_BIT(result, j + 4); |
| 76 } |
| 77 if (inpix & 0x1) { |
| 78 SET_BIT(result, j + 5); |
| 79 } |
51 } | 80 } |
| 81 #else |
| 82 #error Unhandled FB_FORMAT |
| 83 #endif |
| 84 |
52 return MLCD_BYTES_LINE; | 85 return MLCD_BYTES_LINE; |
53 } | 86 } |
OLD | NEW |