Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions pxt-steami/editor/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"compilerOptions": {
"target": "es2017",
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"declaration": true,
"module": "commonjs",
"moduleResolution": "node",
"isolatedModules": false,
"outDir": "../built/editor",
"rootDir": ".",
"newLine": "LF",
"sourceMap": true,
"jsx": "react",
"lib": ["dom", "dom.iterable", "scripthost", "es2017", "ES2018.Promise"]
}
"compilerOptions": {
"target": "es2017",
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"declaration": true,
"module": "commonjs",
"moduleResolution": "node",
"isolatedModules": false,
"outDir": "../built/editor",
"rootDir": ".",
"newLine": "LF",
"sourceMap": true,
"jsx": "react",
"lib": ["dom", "dom.iterable", "scripthost", "es2017", "ES2018.Promise"]
}
}
20 changes: 20 additions & 0 deletions pxt-steami/libs/core/enums.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,24 @@
Reentrant = 8, // MESSAGE_BUS_LISTENER_REENTRANT
}


declare const enum AllColors {
//% block="Red" color=#ff0000
Red = 0,
//% block="Green" color=#00ff00
Green = 1,
//% block="Blue" color=#0000ff
Blue = 2,
//% block="Yellow" color=#ffff00
Yellow = 3,
//% block="Magenta" color=#ff00ff
Magenta = 4,
//% block="Cyan" color=#00ffff
Cyan = 5,
//% block="White" color=#ffffff
White = 6,
}
declare namespace leds {
}

// Auto-generated. Do not edit. Really.
95 changes: 95 additions & 0 deletions pxt-steami/libs/core/leds.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#include "pxt.h"
#include "STeaMi.h"

enum class AllColors {
//% block="Red" color=#ff0000
Red,
//% block="Green" color=#00ff00
Green,
//% block="Blue" color=#0000ff
Blue,
//% block="Yellow" color=#ffff00
Yellow,
//% block="Magenta" color=#ff00ff
Magenta,
//% block="Cyan" color=#00ffff
Cyan,
//% block="White" color=#ffffff
White
};

//% block="leds" weight=100 color=#4287f5 icon=""
namespace leds {
/**
* @brief Set LED RGB off
*/
//% block="set led RGB off" weight=80 group="LED RGB"
//% help=leds/leds_setLedRGBOff
//% blockId="leds_setLedRGBOff" blockGap=8
void setLedRGBOff() {
STM32Pin *led_b = getPin(LED_RGB_Blue); // BLUE
STM32Pin *led_g = getPin(LED_RGB_Green); // GREEN
STM32Pin *led_r = getPin(LED_RGB_Red); // RED
led_b->setDigitalValue(0);
led_g->setDigitalValue(0);
led_r->setDigitalValue(0);
}

/**
* @brief Set LED RGB to color
* @param color Color to set
*/
//% block="set led RGB to %color" weight=80 group="LED RGB"
//% help=leds/leds_setLedRGB
//% blockId="leds_setLedRGB" blockGap=8
void setLedRGB(AllColors color) {
STM32Pin *led_b = getPin(LED_RGB_Blue); // BLUE
STM32Pin *led_g = getPin(LED_RGB_Green); // GREEN
STM32Pin *led_r = getPin(LED_RGB_Red); // RED

switch (color) {
case AllColors::Red:
led_r->setDigitalValue(1);
led_g->setDigitalValue(0);
led_b->setDigitalValue(0);
break;
case AllColors::Green:
led_r->setDigitalValue(0);
led_g->setDigitalValue(1);
led_b->setDigitalValue(0);
break;
case AllColors::Blue:
led_r->setDigitalValue(0);
led_g->setDigitalValue(0);
led_b->setDigitalValue(1);
break;
case AllColors::Yellow:
led_r->setDigitalValue(1);
led_g->setDigitalValue(1);
led_b->setDigitalValue(0);
break;
case AllColors::Magenta:
led_r->setDigitalValue(1);
led_g->setDigitalValue(0);
led_b->setDigitalValue(1);
break;
case AllColors::Cyan:
led_r->setDigitalValue(0);
led_g->setDigitalValue(1);
led_b->setDigitalValue(1);
break;
case AllColors::White:
led_r->setDigitalValue(1);
led_g->setDigitalValue(1);
led_b->setDigitalValue(1);
break;
default:
led_r->setDigitalValue(0);
led_g->setDigitalValue(0);
led_b->setDigitalValue(0);
break;
}
target_wait_us(300);
};

}; // namespace leds
67 changes: 7 additions & 60 deletions pxt-steami/libs/core/pins.h
Original file line number Diff line number Diff line change
@@ -1,66 +1,13 @@
#ifndef __PXT_PINS_H
#define __PXT_PINS_H

#define CFG_PIN_BTN_USER 94
#define CFG_PIN_RESET 95
#define LED_RGB_Blue 42
#define LED_RGB_Green 43
#define LED_RGB_Red 44

#define CFG_PIN_HTS221_SDA 96
#define CFG_PIN_HTS221_SCL 97

#define CFG_PIN_LPS22HB_SDA 98
#define CFG_PIN_LPS22HB_SCL 99

#define CFG_PIN_VL53L0X_SDA 132
#define CFG_PIN_VL53L0X_SCL 133
#define CFG_PIN_VL53L0X_SHUT 134

#define CFG_PIN_LSM6DSL_SDA 135
#define CFG_PIN_LSM6DSL_SCL 136

#define CFG_PIN_BLE_SPI_MISO 137
#define CFG_PIN_BLE_SPI_MOSI 138
#define CFG_PIN_BLE_SPI_SCLK 139
#define CFG_PIN_BLE_SPI_CS 140
#define CFG_PIN_BLE_SPI_IRQ 141
#define CFG_PIN_BLE_RST 142

#define CFG_PIN_WIFI_ISM43362_MOSI 224
#define CFG_PIN_WIFI_ISM43362_MISO 225
#define CFG_PIN_WIFI_ISM43362_SCK 226
#define CFG_PIN_WIFI_ISM43362_CS 227
#define CFG_PIN_WIFI_ISM43362_COMMAND_DATA_READY 228
#define CFG_PIN_WIFI_ISM43362_RESET 229
#define CFG_PIN_WIFI_ISM43362_WAKE_UP 230

#define CFG_PIN_UART1_TX 231
#define CFG_PIN_UART1_RX 232

#define CFG_PIN_UART2_TX 234
#define CFG_PIN_UART2_RX 235

#define CFG_PIN_UART3_TX 236
#define CFG_PIN_UART3_RX 237

#define CFG_PIN_UART4_TX 289
#define CFG_PIN_UART4_RX 290

#define CFG_PIN_SPI1_MISO 291
#define CFG_PIN_SPI1_MOSI 292
#define CFG_PIN_SPI1_SCK 293

#define CFG_PIN_SPI2_MISO 294
#define CFG_PIN_SPI2_MOSI 295
#define CFG_PIN_SPI2_SCK 296

#define CFG_PIN_SPI3_MISO 297
#define CFG_PIN_SPI3_MOSI 298
#define CFG_PIN_SPI3_SCK 299

#define CFG_PIN_I2C1_SCL 332
#define CFG_PIN_I2C1_SDA 333

#define CFG_PIN_I2C2_SCL 334
#define CFG_PIN_I2C2_SDA 335
#define BUTTON_A 7
#define BUTTON_B 8
#define BUTTON_MENU 0

#define BUTTON_ACTIVE_HIGH_PULL_DOWN (ACTIVE_HIGH | 0x10)
#define BUTTON_ACTIVE_HIGH_PULL_UP (ACTIVE_HIGH | 0x20)
Expand Down Expand Up @@ -114,4 +61,4 @@ CodalComponent *lookupComponent(int id);

#define PINOP(op) name->op

#endif
#endif
3 changes: 2 additions & 1 deletion pxt-steami/libs/core/pxt.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
"loops.cpp",
"pause.ts",
"forever.ts",
"usb.cpp"
"usb.cpp",
"leds.cpp"
],

"dependencies": {},
Expand Down
23 changes: 23 additions & 0 deletions pxt-steami/libs/core/shims.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,4 +284,27 @@ declare namespace control {
function isUSBInitialized(): boolean;
}



//% block="leds" weight=100 color=#4287f5 icon=""
declare namespace leds {

/**
* @brief Set LED RGB off
*/
//% block="set led RGB off" weight=80 group="LED RGB"
//% help=leds/leds_setLedRGBOff
//% blockId="leds_setLedRGBOff" blockGap=8 shim=leds::setLedRGBOff
function setLedRGBOff(): void;

/**
* @brief Set LED RGB to color
* @param color Color to set
*/
//% block="set led RGB to %color" weight=80 group="LED RGB"
//% help=leds/leds_setLedRGB
//% blockId="leds_setLedRGB" blockGap=8 shim=leds::setLedRGB
function setLedRGB(color: AllColors): void;
}

// Auto-generated. Do not edit. Really.
44 changes: 44 additions & 0 deletions pxt-steami/libs/leds/sim/leds.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
namespace pxsim.leds {
enum AllColors {
RED = 0,
GREEN = 1,
BLUE = 2,
YELLOW = 3,
MAGENTA = 4,
CYAN = 5,
WHITE = 6,
}

function getHexColor(color: AllColors): string {
switch (color) {
case AllColors.RED:
return '#ff0000';
case AllColors.GREEN:
return '#00ff00';
case AllColors.BLUE:
return '#0000ff';
case AllColors.YELLOW:
return '#ffff00';
case AllColors.MAGENTA:
return '#ff00ff';
case AllColors.CYAN:
return '#00ffff';
case AllColors.WHITE:
return '#ffffff';
default:
return '#000000';
}
}

export function setLedRGBOff(): void {
let ledState = pxsim.ledState();
ledState.setState(6, false, '#000000', 0);
runtime.queueDisplayUpdate();
}

export function setLedRGB(color: AllColors): void {
let ledState = pxsim.ledState();
ledState.setState(6, true, getHexColor(color), 7);
runtime.queueDisplayUpdate();
}
}
64 changes: 64 additions & 0 deletions pxt-steami/libs/leds/sim/ledsBoard.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
namespace pxsim {
export class LedState {
states: {
pin: number;
on: boolean;
color: string;
intensity: number;
}[] = [];

constructor(
states: {
pin: number;
on: boolean;
color: string;
intensity: number;
}[],
) {
this.states = states;
}

setState(
pin: number,
on: boolean,
color: string,
intensity: number,
): void {
const state = this.states.find(s => s.pin === pin);
if (state) {
state.on = on;
state.color = color;
state.intensity = intensity;
} else {
this.states.push({ pin, on, color, intensity });
}
}

getState(pin: number): {
pin: number;
on: boolean;
color: string;
intensity: number;
} {
const state = this.states.find(s => s.pin === pin);
return state;
}

getAllStates(): {
pin: number;
on: boolean;
color: string;
intensity: number;
}[] {
return this.states;
}
}

export interface LedBoard extends CommonBoard {
ledState: LedState;
}

export function ledState(): LedState {
return (board() as LedBoard).ledState;
}
}
10 changes: 10 additions & 0 deletions pxt-steami/libs/leds/sim/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"target": "es5",
"noImplicitAny": true,
"noImplicitReturns": true,
"rootDir": ".",
"newLine": "LF",
"sourceMap": true
}
}
Loading