kopia lustrzana https://github.com/pimoroni/pimoroni-pico
				
				
				
			Updated micropython example to use working submodule
							rodzic
							
								
									aac8c8d2fc
								
							
						
					
					
						commit
						0faa312358
					
				| 
						 | 
				
			
			@ -43,7 +43,7 @@ Button user_sw(plasma2040::USER_SW, Polarity::ACTIVE_LOW, 0);
 | 
			
		|||
Button button_a(plasma2040::BUTTON_A, Polarity::ACTIVE_LOW, 50);
 | 
			
		||||
Button button_b(plasma2040::BUTTON_B, Polarity::ACTIVE_LOW, 50);
 | 
			
		||||
RGBLED led(plasma2040::LED_R, plasma2040::LED_G, plasma2040::LED_B);
 | 
			
		||||
Analog sense(plasma2040::SENSE, plasma2040::ADC_GAIN, plasma2040::SHUNT_RESISTOR);
 | 
			
		||||
Analog sense(plasma2040::CURRENT_SENSE, plasma2040::ADC_GAIN, plasma2040::SHUNT_RESISTOR);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int main() {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -18,7 +18,7 @@ namespace plasma {
 | 
			
		|||
    const uint CLK = 14; // Used only for APA102
 | 
			
		||||
    const uint DAT = 15; // Used for both APA102 and WS2812
 | 
			
		||||
 | 
			
		||||
    const uint SENSE = 29; // The pin used for current sensing
 | 
			
		||||
    const uint CURRENT_SENSE = 29; // The pin used for current sensing
 | 
			
		||||
 | 
			
		||||
    constexpr float ADC_GAIN = 50;
 | 
			
		||||
    constexpr float SHUNT_RESISTOR = 0.015f;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,5 @@
 | 
			
		|||
import plasma
 | 
			
		||||
from plasma import plasma2040
 | 
			
		||||
import time
 | 
			
		||||
 | 
			
		||||
# Import helpers for RGB LEDs, Buttons, and Analog
 | 
			
		||||
| 
						 | 
				
			
			@ -21,16 +22,16 @@ UPDATES = 60
 | 
			
		|||
# Pick *one* LED type by uncommenting the relevant line below:
 | 
			
		||||
 | 
			
		||||
# APA102 / DotStar™ LEDs
 | 
			
		||||
# led_strip = plasma.APA102(NUM_LEDS, 0, 0, plasma.PIN_DAT, plasma.PIN_CLK)
 | 
			
		||||
#led_strip = plasma.APA102(NUM_LEDS, 0, 0, plasma2040.DAT, plasma2040.CLK)
 | 
			
		||||
 | 
			
		||||
# WS2812 / NeoPixel™ LEDs
 | 
			
		||||
led_strip = plasma.WS2812(NUM_LEDS, 0, 0, plasma.PIN_DAT)
 | 
			
		||||
led_strip = plasma.WS2812(NUM_LEDS, 0, 0, plasma2040.DAT)
 | 
			
		||||
 | 
			
		||||
user_sw = Button(plasma.PIN_USER_SW)
 | 
			
		||||
button_a = Button(plasma.PIN_BUTTON_A)
 | 
			
		||||
button_b = Button(plasma.PIN_BUTTON_B)
 | 
			
		||||
led = RGBLED(plasma.PIN_LED_R, plasma.PIN_LED_G, plasma.PIN_LED_B)
 | 
			
		||||
sense = Analog(plasma.PIN_CURRENT_SENSE, plasma.ADC_GAIN, plasma.SHUNT_RESISTOR)
 | 
			
		||||
user_sw = Button(plasma2040.USER_SW)
 | 
			
		||||
button_a = Button(plasma2040.BUTTON_A)
 | 
			
		||||
button_b = Button(plasma2040.BUTTON_B)
 | 
			
		||||
led = RGBLED(plasma2040.LED_R, plasma2040.LED_G, plasma2040.LED_B)
 | 
			
		||||
sense = Analog(plasma2040.CURRENT_SENSE, plasma2040.ADC_GAIN, plasma2040.SHUNT_RESISTOR)
 | 
			
		||||
 | 
			
		||||
# Start updating the LED strip
 | 
			
		||||
led_strip.start()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -69,7 +69,7 @@ STATIC const mp_map_elem_t plasma2040_globals_table[] = {
 | 
			
		|||
    { MP_ROM_QSTR(MP_QSTR_USER_SW), MP_ROM_INT(23) },
 | 
			
		||||
    { MP_ROM_QSTR(MP_QSTR_CLK), MP_ROM_INT(14) },
 | 
			
		||||
    { MP_ROM_QSTR(MP_QSTR_DAT), MP_ROM_INT(15) },
 | 
			
		||||
    { MP_ROM_QSTR(MP_QSTR_SENSE), MP_ROM_INT(29) },
 | 
			
		||||
    { MP_ROM_QSTR(MP_QSTR_CURRENT_SENSE), MP_ROM_INT(29) },
 | 
			
		||||
 | 
			
		||||
    { MP_ROM_QSTR(MP_QSTR_SHUNT_RESISTOR), MP_ROM_PTR(&shunt_resistor) },
 | 
			
		||||
    { MP_ROM_QSTR(MP_QSTR_ADC_GAIN), MP_ROM_INT(50) },
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Ładowanie…
	
		Reference in New Issue