python for linkiot - readthedocs.org

of 35 /35
Python for LinkIoT Release 1.0.0 Nov 27, 2019

Author: others

Post on 11-Apr-2022

0 views

Category:

Documents


0 download

Embed Size (px)

TRANSCRIPT

Python for LinkIoTNov 27, 2019
API and Usage
4 LinkIoT 19
7 25
i
ii
CHAPTER 2
MicroPython
2.1 HBFlash
LinkIoT ArduinoScratch MicroPython LinkIoT MicroPython LinkIoT Python LinkIoT HBFlash LinkIoT
Note: HBFlash LinkIoT MicroPython
2.1.1 HBFlash Windows
2.1.2 HBFlash MacOS
MacOS HBFlash.pkg
MacOS “HBFlash.pkg” HBFlash.pkg
--“”
2.1. HBFlash 5
HBFlash.pkg
2.1. HBFlash 7
2.1. HBFlash 9
Python for LinkIoT, Release 1.0.0
2.2 LinkIoT MicroPython
HBFlash LinkIoT MicroPython HBLinkIoT USB HBFlash USB
10 Chapter 2. MicroPython
Python for LinkIoT, Release 1.0.0
2.2. LinkIoT MicroPython 11
Python for LinkIoT, Release 1.0.0
12 Chapter 2. MicroPython
Python for LinkIoT, Release 1.0.0
2.2. LinkIoT MicroPython 13
Python for LinkIoT, Release 1.0.0
14 Chapter 2. MicroPython
Python for LinkIoT, Release 1.0.0
2.2. LinkIoT MicroPython 15
Python for LinkIoT, Release 1.0.0
16 Chapter 2. MicroPython
CHAPTER 3
18 Chapter 3. Mu
CHAPTER 4
LinkIoT
Import LinkIoT
CHAPTER 5
5.1 Led /
linkiot.setLed(value) value value True Led Led
1
4 ledStatus = False 5
6 while True: 7 linkiot.setLed(ledStatus) 8 ledStatus = not ledStatus 9 utime.sleep_ms(500)
5.2 Led
21
2
4 ledBrightness = 0 5
6 while True: 7 if ledBrightness > 100: 8 ledBrightness = 0 9
10 linkiot.setLedBrightness(ledBrightness) 11 ledBrightness += 10 12 utime.sleep_ms(100)
22 Chapter 5. Led
CHAPTER 6
1 import time 2 from linkiot import * 3
4 while True: 5 if linkiot.button.wasPressed(): 6 print("Button was pressed") 7
8 if linkiot.button.wasReleased(): 9 print("Button was Released")
10
6.2
2
10 linkiot.button.wasPressed(on_wasPressed) 11 linkiot.button.wasReleased(on_wasReleased)
CHAPTER 7
7.1
1
(continues on next page)
(continued from previous page)
7.3 Pitch angleRoll angle
linkiot.anglePitch anglePitch
linkiot.angleRoll angleRoll
4 while True: 5 linkiot.updateAttitude() 6 print("Pitch angle = " + str(linkiot.anglePitch)) 7 print("Roll angle = " + str(linkiot.angleRoll)) 8 utime.sleep(0.2)
7.4
4 while True: 5 linkiot.updateAttitude() 6 if linkiot.wasShaked: 7 print("Shaked") 8 utime.sleep(0.1)
26 Chapter 7.
8.1 Colors
Lcd 24 8 0xFF0000 0xFF00

27

TFT_BLACK 0 TFT_NAVY 128 TFT_BLUE 255 TFT_DARKGREEN 32768 TFT_DARKCYAN 32896 TFT_GREEN 62580 TFT_CYAN 65535 TFT_MAROON 8388608 TFT_PURPLE 8388736 TFT_OLIVE 8421376 TFT_DARKGREY 8421504 TFT_GREENYELLOW 11336748 TFT_LIGHTGREY 12632256 TFT_RED 16515072 TFT_MAGENTA 16515327 TFT_ORANGE 16557056 TFT_PINK 16564426 TFT_YELLOW 16579584 TFT_WHITE 16579836
8.2 Fonts
8.3 Lcd Methods
8.3.2
28 Chapter 8. Lcd
Python for LinkIoT, Release 1.0.0
(x, y) (x1, y1) color
8.3.3
linkiot.Lcd.triangle(x, y, x1, y1, x2, y2 [,color,fillcolor])
(x, y), (x1, y1) (x2, y2) color fillcolor
8.3.4
linkiot.Lcd.rect(x, y, width, height [,color, fillcolor])
(x, y) width height color fillcolor
8.3.5
linkiot.Lcd.circle(x, y, r [, color, fillcolor])
(x, y) r color fillcolor
8.3.6
linkiot.Lcd.ellipse(x, y, rx, ry [,color, fillcolor])
(x, y) x rxy ry color fillcolor
8.3.7
linkiot.Lcd.text(x, y, text [, color])
(x, y) text color
8.3.8
8.3. Lcd Methods 29
8.3.9
1
4
5
10 linkiot.Lcd.setRotation(TFT_LANDSCAPE_FLIP) 11 elif linkiot.accY > 9.0: 12 linkiot.Lcd.setRotation(TFT_PORTRAIT_FLIP) 13 elif linkiot.accY < -9.0: 14 linkiot.Lcd.setRotation(TFT_PORTRAIT) 15
16 ledStatus = False 17
21 linkiot.button.wasPressed(on_wasPressed) 22
Python for LinkIoT, Release 1.0.0
(continued from previous page)
27 if linkiot.wasShaked: 28 print("shaked") 29
30 linkiot.Lcd.clear() 31 linkiot.Lcd.text(0,0,str(linkiot.accX), TFT_GREEN) 32 linkiot.Lcd.text(0,25,str(linkiot.accY), TFT_BLUE) 33 linkiot.Lcd.text(0,50,str(linkiot.accZ), TFT_PURPLE) 34 linkiot.Lcd.text(0,75,str(linkiot.anglePitch), TFT_RED) 35 linkiot.Lcd.text(0,100,str(linkiot.angleRoll), TFT_YELLOW) 36
8.3. Lcd Methods 31