SO CLOSE TO PERFECTION

This commit is contained in:
XANTRONIX Development 2024-01-08 22:00:30 -05:00
parent 977734b00b
commit 7c031aa63b
2 changed files with 20 additions and 5 deletions

View file

@ -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, <object>fg, window, &frame)
hexagram_window_destroy(window)
return 0

View file

@ -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: