Skip to content

Commit

Permalink
Add v0.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
xuefengedu authored Jun 19, 2019
1 parent e9e732e commit 977aa4b
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 8 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ ESP-01 makecode extension for micro:bit

![Alt text](https://github.com/51bit/esp01/raw/master/icon.png?raw=true "ESP-01")

Pre-design PCB:
![Alt text](https://github.com/51bit/esp01/raw/master/version0.1.jpg?raw=true "ESP-01 for micro:bit")

## Basic Usage

```blocks
Expand All @@ -29,7 +32,7 @@ basic.forever(function () {
pass = 1
pins.digitalWritePin(DigitalPin.P16, 1)
}
esp01.serveWebHTML(pass == 1, 0)
esp01.serveWebHTML(pass == 1)
})
input.onButtonPressed(Button.A, function () {
basic.showString(esp01.newline())
Expand Down
2 changes: 1 addition & 1 deletion _locales/zh/esp01-strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"esp01.disconnectFromWiFiRouter|block": "断开WiFi路由器连接",
"esp01.setupAPServer|block": "设置AP Web服务器:%ssid, %password",
"esp01.getAPWebRequest|block": "获取AP web请求",
"esp01.serveWebHTML|block": "托管Web网页,页面正确: %getSuccess, 设置LED状态: %LED_status",
"esp01.serveWebHTML|block": "托管Web网页,页面正确: %getSuccess",
"esp01.sendHttp|block": "执行HTTP方法: %method|主机: %host|端口: %port|路径: %urlPath|报头headers: %headers|主体body: %body",
"esp01.sendHttpAndResponse|block": "发送HTTP方法: %method|主机: %host|端口: %port|路径: %urlPath|报头headers: %headers|主体body: %body"
}
20 changes: 16 additions & 4 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace esp01 {
let sendSerialTimeout: number = 1000
let serial_str: string = ""
let client_ID: string = ""
let LED_status: number = 0x0

// for wifi connection
function wait_for_response(str: string): boolean {
Expand Down Expand Up @@ -127,7 +128,7 @@ namespace esp01 {

// generate HTML
// LED_status=0x23be, 0x23be=0000 0000 0010 0011 1011 1110
function getHTML(normal: boolean, LED_status: number): string {
function getHTML(normal: boolean): string {
let LED_statusString: string = ""
let LED_buttonString: string = ""
let web_title: string = "ESP8266 (ESP-01) Wifi on BBC micro:bit"
Expand Down Expand Up @@ -206,18 +207,29 @@ namespace esp01 {
break
}
}
let posLED = getCommand.indexOf("LED")
if (posLED != -1) {
let getNum = parseInt(getCommand.substr(3, getCommand.length - posLED - 1)) - 1
let a = LED_status >> getNum

if ((a & 1) == 0) {
LED_status = LED_status | (1 << getNum)
}
else {
LED_status = (LED_status & ~(1 << getNum))
}
}
return getCommand
}

/**
* Serve Web HTML.
* @param getSuccess getSuccess, eg: true
* @param LED_status LED_status, eg: 0x23be
*/
//% weight=95
//% group="Wifi Server Suite"
//% blockId="esp01_serve_webhtml" block="serve Web HTML, success page: %getSuccess, set LED status: %LED_status"
export function serveWebHTML(getSuccess: boolean = true, LED_status: number): void {
//% blockId="esp01_serve_webhtml" block="serve Web HTML, success page: %getSuccess"
export function serveWebHTML(getSuccess: boolean = true): void {
// output HTML
let HTML_str: string = ""
if (getSuccess) {
Expand Down
2 changes: 1 addition & 1 deletion pxt.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "esp01",
"version": "0.0.4",
"version": "0.0.5",
"description": "esp01 for micro:bit",
"license": "MIT",
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ basic.forever(function () {
pass = 1
pins.digitalWritePin(DigitalPin.P16, 1)
}
esp01.serveWebHTML(pass == 1, 0)
esp01.serveWebHTML(pass == 1)
})
input.onButtonPressed(Button.A, function () {
basic.showString(esp01.newline())
Expand Down
Binary file added version0.1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 977aa4b

Please sign in to comment.