From 609ab9c79fc5e78a42088d90af42aad8df73e623 Mon Sep 17 00:00:00 2001 From: Andrew Scheller Date: Fri, 16 Aug 2024 16:14:11 +0100 Subject: [PATCH] Trim trailing whitespace from example Micropython code --- adc/temperature.py | 4 ++-- bluetooth/picow_ble_temp_reader.py | 4 ++-- bluetooth/picow_ble_temp_sensor.py | 8 ++++---- i2c/1106oled/i2c_1106oled_using_defaults.py | 5 ++--- i2c/1106oled/i2c_1106oled_with_freq.py | 2 +- i2c/1306oled/i2c_1306oled_using_defaults.py | 2 +- i2c/1306oled/i2c_1306oled_with_freq.py | 2 +- i2c/i2c.py | 2 +- pio/neopixel_ring/neopixel_ring.py | 11 +++++------ 9 files changed, 19 insertions(+), 21 deletions(-) diff --git a/adc/temperature.py b/adc/temperature.py index 77b78ea..d0af08f 100644 --- a/adc/temperature.py +++ b/adc/temperature.py @@ -6,9 +6,9 @@ conversion_factor = 3.3 / (65535) while True: reading = sensor_temp.read_u16() * conversion_factor - + # The temperature sensor measures the Vbe voltage of a biased bipolar diode, connected to the fifth ADC channel - # Typically, Vbe = 0.706V at 27 degrees C, with a slope of -1.721mV (0.001721) per degree. + # Typically, Vbe = 0.706V at 27 degrees C, with a slope of -1.721mV (0.001721) per degree. temperature = 27 - (reading - 0.706)/0.001721 print(temperature) utime.sleep(2) diff --git a/bluetooth/picow_ble_temp_reader.py b/bluetooth/picow_ble_temp_reader.py index da82e5c..79c8e77 100644 --- a/bluetooth/picow_ble_temp_reader.py +++ b/bluetooth/picow_ble_temp_reader.py @@ -221,7 +221,7 @@ class BLETemperatureCentral: def sleep_ms_flash_led(self, flash_count, delay_ms): self._led.off() while(delay_ms > 0): - for i in range(flash_count): + for i in range(flash_count): self._led.on() time.sleep_ms(100) self._led.off() @@ -267,4 +267,4 @@ if __name__ == "__main__": central = BLETemperatureCentral(ble) while(True): demo(ble, central) - sleep_ms_flash_led(central, 1, 10000) \ No newline at end of file + sleep_ms_flash_led(central, 1, 10000) diff --git a/bluetooth/picow_ble_temp_sensor.py b/bluetooth/picow_ble_temp_sensor.py index c55dcc8..a7d98bc 100644 --- a/bluetooth/picow_ble_temp_sensor.py +++ b/bluetooth/picow_ble_temp_sensor.py @@ -86,11 +86,11 @@ class BLETemperature: def _get_temp(self): conversion_factor = 3.3 / (65535) reading = self._sensor_temp.read_u16() * conversion_factor - + # The temperature sensor measures the Vbe voltage of a biased bipolar diode, connected to the fifth ADC channel - # Typically, Vbe = 0.706V at 27 degrees C, with a slope of -1.721mV (0.001721) per degree. + # Typically, Vbe = 0.706V at 27 degrees C, with a slope of -1.721mV (0.001721) per degree. return 27 - (reading - 0.706) / 0.001721 - + def demo(): ble = bluetooth.BLE() temp = BLETemperature(ble) @@ -104,4 +104,4 @@ def demo(): counter += 1 if __name__ == "__main__": - demo() \ No newline at end of file + demo() diff --git a/i2c/1106oled/i2c_1106oled_using_defaults.py b/i2c/1106oled/i2c_1106oled_using_defaults.py index 53df68a..b727194 100644 --- a/i2c/1106oled/i2c_1106oled_using_defaults.py +++ b/i2c/1106oled/i2c_1106oled_using_defaults.py @@ -1,9 +1,8 @@ - # Display Image & text on I2C driven SH1106 OLED display +# Display Image & text on I2C driven SH1106 OLED display from machine import I2C, ADC from sh1106 import SH1106_I2C import framebuf - WIDTH = 128 # oled display width HEIGHT = 128 # oled display height @@ -31,4 +30,4 @@ oled.text("Raspberry Pi",5,5) oled.text("Pico",5,15) # Finally update the oled display so the image & text is displayed -oled.show() \ No newline at end of file +oled.show() diff --git a/i2c/1106oled/i2c_1106oled_with_freq.py b/i2c/1106oled/i2c_1106oled_with_freq.py index 1347206..0c0e08a 100644 --- a/i2c/1106oled/i2c_1106oled_with_freq.py +++ b/i2c/1106oled/i2c_1106oled_with_freq.py @@ -1,4 +1,4 @@ -# Display Image & text on I2C driven ssd1306 OLED display +# Display Image & text on I2C driven ssd1306 OLED display from machine import Pin, I2C from sh1106 import SH1106_I2C import framebuf diff --git a/i2c/1306oled/i2c_1306oled_using_defaults.py b/i2c/1306oled/i2c_1306oled_using_defaults.py index 2c87376..7ad8235 100644 --- a/i2c/1306oled/i2c_1306oled_using_defaults.py +++ b/i2c/1306oled/i2c_1306oled_using_defaults.py @@ -1,4 +1,4 @@ - # Display Image & text on I2C driven ssd1306 OLED display +# Display Image & text on I2C driven ssd1306 OLED display from machine import Pin, I2C from ssd1306 import SSD1306_I2C import framebuf diff --git a/i2c/1306oled/i2c_1306oled_with_freq.py b/i2c/1306oled/i2c_1306oled_with_freq.py index 76133d7..f67cd0f 100644 --- a/i2c/1306oled/i2c_1306oled_with_freq.py +++ b/i2c/1306oled/i2c_1306oled_with_freq.py @@ -1,4 +1,4 @@ -# Display Image & text on I2C driven ssd1306 OLED display +# Display Image & text on I2C driven ssd1306 OLED display from machine import Pin, I2C from ssd1306 import SSD1306_I2C import framebuf diff --git a/i2c/i2c.py b/i2c/i2c.py index f59281a..a3b6b00 100644 --- a/i2c/i2c.py +++ b/i2c/i2c.py @@ -1,6 +1,6 @@ from machine import Pin, I2C -i2c = I2C(0, scl=Pin(9), sda=Pin(8), freq=100000) +i2c = I2C(0, scl=Pin(9), sda=Pin(8), freq=100000) i2c.scan() i2c.writeto(76, b'123') i2c.readfrom(76, 4) diff --git a/pio/neopixel_ring/neopixel_ring.py b/pio/neopixel_ring/neopixel_ring.py index 0a8c407..7710cf1 100644 --- a/pio/neopixel_ring/neopixel_ring.py +++ b/pio/neopixel_ring/neopixel_ring.py @@ -57,7 +57,7 @@ def color_chase(color, wait): time.sleep(wait) pixels_show() time.sleep(0.2) - + def wheel(pos): # Input a value 0 to 255 to get a color value. # The colours are a transition r - g - b - back to r. @@ -70,8 +70,7 @@ def wheel(pos): return (0, 255 - pos * 3, pos * 3) pos -= 170 return (pos * 3, 0, 255 - pos * 3) - - + def rainbow_cycle(wait): for j in range(255): for i in range(NUM_LEDS): @@ -91,14 +90,14 @@ WHITE = (255, 255, 255) COLORS = (BLACK, RED, YELLOW, GREEN, CYAN, BLUE, PURPLE, WHITE) print("fills") -for color in COLORS: +for color in COLORS: pixels_fill(color) pixels_show() time.sleep(0.2) print("chases") -for color in COLORS: +for color in COLORS: color_chase(color, 0.01) print("rainbow") -rainbow_cycle(0) \ No newline at end of file +rainbow_cycle(0)