Merge pull request from raspberrypi/trim_whitespace

Trim trailing whitespace from example Micropython code
master
nate contino 2024-08-16 16:24:01 +01:00 zatwierdzone przez GitHub
commit 1dc8d73a08
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
9 zmienionych plików z 19 dodań i 21 usunięć

Wyświetl plik

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

Wyświetl plik

@ -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)
sleep_ms_flash_led(central, 1, 10000)

Wyświetl plik

@ -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()
demo()

Wyświetl plik

@ -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()
oled.show()

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

@ -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)
rainbow_cycle(0)