Explorar o código

update: zbuff的framebuffer都改成小端的

chenxuuu %!s(int64=4) %!d(string=hai) anos
pai
achega
7db336d6e4
Modificáronse 2 ficheiros con 23 adicións e 17 borrados
  1. 0 3
      luat/modules/SConscript
  2. 23 14
      luat/modules/luat_lib_zbuff.c

+ 0 - 3
luat/modules/SConscript

@@ -26,9 +26,6 @@ if not GetDepend(['SAL_USING_POSIX']):
     src.remove('luat_lib_socket.c')
 if not GetDepend(['RT_USING_ADC']):
     src.remove('luat_lib_adc.c')
-if not GetDepend(['PKG_USING_U8G2']):
-    src.remove('luat_lib_disp.c')
-    src.remove('luat_lib_u8g2.c')
 
 src.remove('luat_shell.c')
 src.remove('luat_lib_lpmem.c')

+ 23 - 14
luat/modules/luat_lib_zbuff.c

@@ -34,11 +34,18 @@ int add_bytes(luat_zbuff *buff, const char *source, size_t len)
     buff->addr[point / 2] &= (point % 2) ? 0xf0 : 0x0f; \
     buff->addr[point / 2] |= (point % 2) ? color : (color * 0x10)
 #define SET_POINT_8(buff, point, color) buff->addr[point] = color
-#define SET_POINT_16(buff, point, color) *((uint16_t *)buff->addr + point) = color
-#define SET_POINT_24(buff, point, color)     \
-    buff->addr[point * 3] = color / 0x10000; \
-    *((uint16_t *)(buff->addr + point * 3 + 1)) = color % 0x10000;
-#define SET_POINT_32(buff, point, color) *((uint32_t *)buff->addr + point) = color
+#define SET_POINT_16(buff, point, color) \
+    buff->addr[point] = color / 0x100;   \
+    buff->addr[point + 1] = color % 0x100
+#define SET_POINT_24(buff, point, color)                              \
+    buff->addr[point * 3] = color / 0x10000;                          \
+    buff->addr[point * 3 + 1] = color % 0x10000 / 0x100; \
+    buff->addr[point * 3 + 2] = color % 0x100
+#define SET_POINT_32(buff, point, color)                 \
+    buff->addr[point] = color / 0x1000000;               \
+    buff->addr[point + 1] = color % 0x1000000 / 0x10000; \
+    buff->addr[point + 2] = color % 0x10000 / 0x100;     \
+    buff->addr[point + 3] = color % 0x100
 
 #define SET_POINT_CASE(n, point, color)    \
     case n:                                \
@@ -58,15 +65,17 @@ int add_bytes(luat_zbuff *buff, const char *source, size_t len)
         break;                                    \
     }
 
-#define GET_POINT_1(buff, point) return (buff->addr[point / 8] >> (7 - point % 8)) % 2
-#define GET_POINT_4(buff, point) return (buff->addr[point / 2] >> ((point % 2)?0:4)) % 0x10
-#define GET_POINT_8(buff, point) return buff->addr[point]
-#define GET_POINT_16(buff, point) return *((uint16_t *)buff->addr + point)
-#define GET_POINT_24(buff, point) return buff->addr[point * 3] * 0x10000 + *((uint16_t *)(buff->addr + point * 3 + 1))
-#define GET_POINT_32(buff, point) return *((uint32_t *)buff->addr + point)
-#define GET_POINT_CASE(n, point)    \
-    case n:                         \
-        GET_POINT_##n(buff, point); \
+#define GET_POINT_1(buff, point) (buff->addr[point / 8] >> (7 - point % 8)) % 2
+#define GET_POINT_4(buff, point) (buff->addr[point / 2] >> ((point % 2) ? 0 : 4)) % 0x10
+#define GET_POINT_8(buff, point) buff->addr[point]
+#define GET_POINT_16(buff, point) buff->addr[point] * 0x100 + buff->addr[point + 1]
+#define GET_POINT_24(buff, point) \
+    buff->addr[point * 3] * 0x10000 + buff->addr[point * 3 + 1] * 0x100 + buff->addr[point * 3 + 2]
+#define GET_POINT_32(buff, point) \
+    buff->addr[point] * 0x1000000 + buff->addr[point + 1] * 0x10000 + buff->addr[point + 2] * 0x100 + buff->addr[point + 3]
+#define GET_POINT_CASE(n, point)           \
+    case n:                                \
+        return GET_POINT_##n(buff, point); \
         break
 //获取某点的颜色
 uint32_t get_framebuffer_point(luat_zbuff *buff,uint32_t point)