kopia lustrzana https://github.com/pimoroni/pimoroni-pico
Porównaj commity
1 Commity
8cf276b992
...
ecc3df7528
Autor | SHA1 | Data |
---|---|---|
Phil Howard | ecc3df7528 |
|
@ -494,14 +494,11 @@ namespace pimoroni {
|
|||
void CosmicUnicorn::set_brightness(float value) {
|
||||
value = value < 0.0f ? 0.0f : value;
|
||||
value = value > 1.0f ? 1.0f : value;
|
||||
// Max brightness is - in fact - 256 since it's applied with:
|
||||
// result = (channel * brightness) >> 8
|
||||
// eg: (255 * 256) >> 8 == 255
|
||||
this->brightness = floor(value * 256.0f);
|
||||
}
|
||||
|
||||
float CosmicUnicorn::get_brightness() {
|
||||
return this->brightness / 256.0f;
|
||||
return this->brightness / 255.0f;
|
||||
}
|
||||
|
||||
void CosmicUnicorn::adjust_brightness(float delta) {
|
||||
|
|
|
@ -488,14 +488,11 @@ namespace pimoroni {
|
|||
void GalacticUnicorn::set_brightness(float value) {
|
||||
value = value < 0.0f ? 0.0f : value;
|
||||
value = value > 1.0f ? 1.0f : value;
|
||||
// Max brightness is - in fact - 256 since it's applied with:
|
||||
// result = (channel * brightness) >> 8
|
||||
// eg: (255 * 256) >> 8 == 255
|
||||
this->brightness = floor(value * 256.0f);
|
||||
}
|
||||
|
||||
float GalacticUnicorn::get_brightness() {
|
||||
return this->brightness / 256.0f;
|
||||
return this->brightness / 255.0f;
|
||||
}
|
||||
|
||||
void GalacticUnicorn::adjust_brightness(float delta) {
|
||||
|
|
|
@ -485,14 +485,11 @@ namespace pimoroni {
|
|||
void StellarUnicorn::set_brightness(float value) {
|
||||
value = value < 0.0f ? 0.0f : value;
|
||||
value = value > 1.0f ? 1.0f : value;
|
||||
// Max brightness is - in fact - 256 since it's applied with:
|
||||
// result = (channel * brightness) >> 8
|
||||
// eg: (255 * 256) >> 8 == 255
|
||||
this->brightness = floor(value * 256.0f);
|
||||
}
|
||||
|
||||
float StellarUnicorn::get_brightness() {
|
||||
return this->brightness / 256.0f;
|
||||
return this->brightness / 255.0f;
|
||||
}
|
||||
|
||||
void StellarUnicorn::adjust_brightness(float delta) {
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
import time
|
||||
from machine import Pin
|
||||
from pimoroni_i2c import PimoroniI2C
|
||||
from breakout_ltr559 import BreakoutLTR559
|
||||
|
||||
PINS_BREAKOUT_GARDEN = {"sda": 4, "scl": 5}
|
||||
PINS_PICO_EXPLORER = {"sda": 20, "scl": 21}
|
||||
PIN_INTERRUPT = 22 # 3 for Breakout Garden
|
||||
|
||||
i2c = PimoroniI2C(**PINS_PICO_EXPLORER)
|
||||
ltr = BreakoutLTR559(i2c, interrupt=PIN_INTERRUPT)
|
||||
interrupt = Pin(PIN_INTERRUPT, Pin.IN, Pin.PULL_DOWN)
|
||||
|
||||
ltr.light_threshold(0, 10) # COUNTS, NOT LUX!!!
|
||||
ltr.proximity_threshold(0, 10)
|
||||
|
||||
|
||||
def read(pin):
|
||||
reading = ltr.get_reading()
|
||||
if reading is not None:
|
||||
print("T: ", time.ticks_ms(), " Lux: ", reading[BreakoutLTR559.LUX], " Prox: ", reading[BreakoutLTR559.PROXIMITY])
|
||||
|
||||
|
||||
interrupt.irq(trigger=Pin.IRQ_RISING, handler=read)
|
||||
|
||||
part_id = ltr.part_id()
|
||||
print("Found LTR559. Part ID: 0x", '{:02x}'.format(part_id), sep="")
|
||||
|
||||
while True:
|
||||
pass
|
Ładowanie…
Reference in New Issue