summaryrefslogtreecommitdiff
path: root/shared-module
diff options
context:
space:
mode:
authorDan Halbert <halbert@halwitz.org>2020-05-04 17:26:59 -0400
committerDan Halbert <halbert@halwitz.org>2020-05-04 17:26:59 -0400
commitbae7a5e4337bd7a05af6f68e7668c39dd78fa1e1 (patch)
tree8fdd5d8b512fd0eaa5d81929155cec61184020af /shared-module
parentd6c6f9f4f080d60716b148aed951462a065074d2 (diff)
parent4d7e341e44ac40d18e947643ab925cbd7812cd36 (diff)
make translate again
Diffstat (limited to 'shared-module')
-rw-r--r--shared-module/displayio/Display.c2
-rw-r--r--shared-module/displayio/EPaperDisplay.c2
-rw-r--r--shared-module/displayio/FourWire.c2
-rw-r--r--shared-module/displayio/I2CDisplay.c2
-rw-r--r--shared-module/displayio/display_core.c2
-rw-r--r--shared-module/framebufferio/FramebufferDisplay.c2
-rw-r--r--shared-module/time/__init__.c45
-rw-r--r--shared-module/usb_hid/Device.c2
8 files changed, 46 insertions, 13 deletions
diff --git a/shared-module/displayio/Display.c b/shared-module/displayio/Display.c
index aaddbb471..da5713f8c 100644
--- a/shared-module/displayio/Display.c
+++ b/shared-module/displayio/Display.c
@@ -41,8 +41,6 @@
#include <stdint.h>
#include <string.h>
-#include "tick.h"
-
void common_hal_displayio_display_construct(displayio_display_obj_t* self,
mp_obj_t bus, uint16_t width, uint16_t height, int16_t colstart, int16_t rowstart,
uint16_t rotation, uint16_t color_depth, bool grayscale, bool pixels_in_byte_share_row,
diff --git a/shared-module/displayio/EPaperDisplay.c b/shared-module/displayio/EPaperDisplay.c
index 5b4a8f916..6a55687b9 100644
--- a/shared-module/displayio/EPaperDisplay.c
+++ b/shared-module/displayio/EPaperDisplay.c
@@ -42,8 +42,6 @@
#include <stdint.h>
#include <string.h>
-#include "tick.h"
-
void common_hal_displayio_epaperdisplay_construct(displayio_epaperdisplay_obj_t* self,
mp_obj_t bus, uint8_t* start_sequence, uint16_t start_sequence_len, uint8_t* stop_sequence, uint16_t stop_sequence_len,
uint16_t width, uint16_t height, uint16_t ram_width, uint16_t ram_height,
diff --git a/shared-module/displayio/FourWire.c b/shared-module/displayio/FourWire.c
index fe7234aa7..17e8cfa1d 100644
--- a/shared-module/displayio/FourWire.c
+++ b/shared-module/displayio/FourWire.c
@@ -36,8 +36,6 @@
#include "shared-bindings/time/__init__.h"
#include "shared-module/displayio/display_core.h"
-#include "tick.h"
-
void common_hal_displayio_fourwire_construct(displayio_fourwire_obj_t* self,
busio_spi_obj_t* spi, const mcu_pin_obj_t* command,
const mcu_pin_obj_t* chip_select, const mcu_pin_obj_t* reset, uint32_t baudrate,
diff --git a/shared-module/displayio/I2CDisplay.c b/shared-module/displayio/I2CDisplay.c
index 280476f19..0c8f2e69a 100644
--- a/shared-module/displayio/I2CDisplay.c
+++ b/shared-module/displayio/I2CDisplay.c
@@ -38,8 +38,6 @@
#include "shared-bindings/time/__init__.h"
#include "shared-module/displayio/display_core.h"
-#include "tick.h"
-
void common_hal_displayio_i2cdisplay_construct(displayio_i2cdisplay_obj_t* self,
busio_i2c_obj_t* i2c, uint16_t device_address, const mcu_pin_obj_t* reset) {
diff --git a/shared-module/displayio/display_core.c b/shared-module/displayio/display_core.c
index 4cc7564d0..d01100f7f 100644
--- a/shared-module/displayio/display_core.c
+++ b/shared-module/displayio/display_core.c
@@ -40,8 +40,6 @@
#include <stdint.h>
#include <string.h>
-#include "tick.h"
-
void displayio_display_core_construct(displayio_display_core_t* self,
mp_obj_t bus, uint16_t width, uint16_t height, uint16_t ram_width, uint16_t ram_height, int16_t colstart, int16_t rowstart, uint16_t rotation,
uint16_t color_depth, bool grayscale, bool pixels_in_byte_share_row, uint8_t bytes_per_cell, bool reverse_pixels_in_byte, bool reverse_bytes_in_word) {
diff --git a/shared-module/framebufferio/FramebufferDisplay.c b/shared-module/framebufferio/FramebufferDisplay.c
index 13fbb2629..2a88b5307 100644
--- a/shared-module/framebufferio/FramebufferDisplay.c
+++ b/shared-module/framebufferio/FramebufferDisplay.c
@@ -40,8 +40,6 @@
#include <stdint.h>
#include <string.h>
-#include "tick.h"
-
void common_hal_framebufferio_framebufferdisplay_construct(framebufferio_framebufferdisplay_obj_t* self,
mp_obj_t framebuffer,
uint16_t rotation,
diff --git a/shared-module/time/__init__.c b/shared-module/time/__init__.c
new file mode 100644
index 000000000..347e68ae0
--- /dev/null
+++ b/shared-module/time/__init__.c
@@ -0,0 +1,45 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2016 Scott Shawcroft for Adafruit Industries
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "py/mphal.h"
+#include "supervisor/port.h"
+#include "supervisor/shared/tick.h"
+
+uint64_t common_hal_time_monotonic(void) {
+ return supervisor_ticks_ms64();
+}
+
+uint64_t common_hal_time_monotonic_ns(void) {
+ uint8_t subticks = 0;
+ uint64_t ticks = port_get_raw_ticks(&subticks);
+ // A tick is 976562.5 nanoseconds so multiply it by the base and add half instead of doing float
+ // math.
+ return 976562 * ticks + ticks / 2 + 30518 * subticks;
+}
+
+void common_hal_time_delay_ms(uint32_t delay) {
+ mp_hal_delay_ms(delay);
+}
diff --git a/shared-module/usb_hid/Device.c b/shared-module/usb_hid/Device.c
index 8744f2ed3..8e9df6f04 100644
--- a/shared-module/usb_hid/Device.c
+++ b/shared-module/usb_hid/Device.c
@@ -25,7 +25,7 @@
*/
#include <string.h>
-#include "tick.h"
+
#include "py/runtime.h"
#include "shared-bindings/usb_hid/Device.h"
#include "shared-module/usb_hid/Device.h"