From 7bb0f7b0f6218e813ca1ea9a21d5d549c7b36ab9 Mon Sep 17 00:00:00 2001
From: Damien George <damien.p.george@gmail.com>
Date: Thu, 3 Nov 2016 12:41:11 +1100
Subject: [PATCH] drivers: Add "from micropython import const" when const is
 used.

Following best-practice use of the const feature, to make it compatible
with Python.
---
 drivers/display/ssd1306.py           | 1 +
 drivers/nrf24l01/nrf24l01.py         | 1 +
 drivers/sdcard/sdcard.py             | 1 +
 esp8266/modules/ds18x20.py           | 2 ++
 esp8266/modules/onewire.py           | 1 +
 stmhal/boards/STM32F4DISC/staccel.py | 1 +
 6 files changed, 7 insertions(+)

diff --git a/drivers/display/ssd1306.py b/drivers/display/ssd1306.py
index 34dca769e..ad57725e7 100644
--- a/drivers/display/ssd1306.py
+++ b/drivers/display/ssd1306.py
@@ -1,5 +1,6 @@
 # MicroPython SSD1306 OLED driver, I2C and SPI interfaces
 
+from micropython import const
 import time
 import framebuf
 
diff --git a/drivers/nrf24l01/nrf24l01.py b/drivers/nrf24l01/nrf24l01.py
index a244b0b25..3c79650bf 100644
--- a/drivers/nrf24l01/nrf24l01.py
+++ b/drivers/nrf24l01/nrf24l01.py
@@ -1,6 +1,7 @@
 """NRF24L01 driver for Micro Python
 """
 
+from micropython import const
 import pyb
 
 # nRF24L01+ registers
diff --git a/drivers/sdcard/sdcard.py b/drivers/sdcard/sdcard.py
index fc7a8af7c..191630aeb 100644
--- a/drivers/sdcard/sdcard.py
+++ b/drivers/sdcard/sdcard.py
@@ -21,6 +21,7 @@ Example usage on ESP8266:
 
 """
 
+from micropython import const
 import time
 
 
diff --git a/esp8266/modules/ds18x20.py b/esp8266/modules/ds18x20.py
index fc53048f8..bf0609483 100644
--- a/esp8266/modules/ds18x20.py
+++ b/esp8266/modules/ds18x20.py
@@ -1,6 +1,8 @@
 # DS18x20 temperature sensor driver for MicroPython.
 # MIT license; Copyright (c) 2016 Damien P. George
 
+from micropython import const
+
 _CONVERT = const(0x44)
 _RD_SCRATCH = const(0xbe)
 _WR_SCRATCH = const(0x4e)
diff --git a/esp8266/modules/onewire.py b/esp8266/modules/onewire.py
index 06b216a57..83318d1a4 100644
--- a/esp8266/modules/onewire.py
+++ b/esp8266/modules/onewire.py
@@ -1,6 +1,7 @@
 # 1-Wire driver for MicroPython on ESP8266
 # MIT license; Copyright (c) 2016 Damien P. George
 
+from micropython import const
 import _onewire as _ow
 
 class OneWireError(Exception):
diff --git a/stmhal/boards/STM32F4DISC/staccel.py b/stmhal/boards/STM32F4DISC/staccel.py
index 7296662ca..2f2561d1c 100644
--- a/stmhal/boards/STM32F4DISC/staccel.py
+++ b/stmhal/boards/STM32F4DISC/staccel.py
@@ -14,6 +14,7 @@ See:
     STM32Cube_FW_F4_V1.1.0/Projects/STM32F4-Discovery/Demonstrations/Src/main.c
 """
 
+from micropython import const
 from pyb import Pin
 from pyb import SPI
 
-- 
GitLab