]> git.karo-electronics.de Git - oswald.git/blobdiff - metawatch/oswald_hal.c
Add clipping for LCD draw_pixel
[oswald.git] / metawatch / oswald_hal.c
index 449355dabddc3b7129edecefb6f38d82b0b71f00..8c802c4e5360157f1feeb377c90f9def2e6c5bb1 100644 (file)
@@ -14,6 +14,7 @@
 #include "bt_hci.h"
 #include "bt_l2cap.h"
 #include "bluetooth_init_cc256x.h"
+#include "mw_acc.h"
 
 #include "oswald.h"
 #include "oswald_hal.h"
@@ -38,8 +39,10 @@ const char *hal_get_radio_version_string(void)
 
 void hal_lcd_set_pixel(uint8_t x, uint8_t y, uint8_t color)
 {
-       x %= 96;
-       y %= 96;
+       if (x > 95)
+               x = 95;
+       if (y > 95)
+               y = 95;
        mw_lcd_draw_pixel(x, y, color ? LCD_BLACK : LCD_WHITE);
 }
 
@@ -96,6 +99,7 @@ void hal_get_rtc(clock_state *rtc)
        rtc->day = RTCDAY;
        rtc->month = RTCMON;
        rtc->year = RTCYEAR;
+       rtc->wday = RTCDOW;
 }
 
 void hal_set_rtc(clock_state *rtc, boolean set_sec)
@@ -249,3 +253,21 @@ void hal_bluetooth_send_data(const void *mdat, uint16_t mlen)
        bt_l2cap_send_channel(0x40, mdat, mlen);
 }
 
+/*
+ * Control the accelerometer
+ */
+void hal_accelerometer_enable(void)
+{
+       mw_acc_enable();
+}
+
+void hal_accelerometer_disable(void)
+{
+       mw_acc_disable();
+}
+
+uint16_t hal_amblight_get_val(void)
+{
+       return mw_get_amblight_adc_val();
+}
+