From 7c031aa63bdfff34dcc983e8817c61f2ed773a68 Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Mon, 8 Jan 2024 22:00:30 -0500 Subject: [PATCH] SO CLOSE TO PERFECTION --- py/hexagram/app.pyx | 14 +++++++++++--- py/hexagram/can.pxd | 11 +++++++++-- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/py/hexagram/app.pyx b/py/hexagram/app.pyx index c22341d..8f26c5c 100755 --- a/py/hexagram/app.pyx +++ b/py/hexagram/app.pyx @@ -12,8 +12,6 @@ from hexagram.window cimport * from hexagram.cluster import Cluster -CLUSTER_WIDTH = 1280 -CLUSTER_HEIGHT = 480 CLUSTER_RPM_MIN = 1200 CLUSTER_RPM_REDLINE = 6500 CLUSTER_RPM_MAX = 8000 @@ -37,6 +35,14 @@ cdef handle_xevents(hexagram_window *window, cluster.draw_fg(fg) hexagram_window_swap_buffer(window) +cdef cluster_update(cluster: Cluster, + fg: cairo.Context, + hexagram_window *window, + can_frame *frame): + hexagram_window_refresh_bg(window) + cluster.draw_fg(fg) + hexagram_window_swap_buffer(window) + def main(): cdef fd_set rfds, rready cdef can_frame frame @@ -51,7 +57,7 @@ def main(): if can_if is NULL: raise Exception("hexagram_can_if_open()") - window = hexagram_window_new_x11(NULL, CLUSTER_WIDTH, CLUSTER_HEIGHT) + window = hexagram_window_new_x11(NULL, Cluster.WIDTH, Cluster.HEIGHT) if window is NULL: raise Exception("hexagram_window_new_x11()") @@ -99,6 +105,8 @@ def main(): if FD_ISSET(fd, &rready): hexagram_can_if_read(can_if, &frame) + cluster_update(cluster, fg, window, &frame) + hexagram_window_destroy(window) return 0 diff --git a/py/hexagram/can.pxd b/py/hexagram/can.pxd index 222d259..b804655 100644 --- a/py/hexagram/can.pxd +++ b/py/hexagram/can.pxd @@ -1,10 +1,17 @@ +from libc.stdint cimport uint8_t, uint32_t + cdef extern from "sys/select.h": ctypedef struct fd_set: pass cdef extern from "linux/can.h": - cdef struct can_frame: - pass + cdef packed struct can_frame: + uint32_t can_id + uint8_t len + uint8_t __pad + uint8_t __res0 + uint8_t __len8_dlc + uint8_t data[8] cdef extern from "hexagram/can.h": ctypedef struct hexagram_can_if: