fixed some warnings

This commit is contained in:
watson8544
2018-09-19 11:12:18 +08:00
parent 2c7aee72de
commit 44892430db
9 changed files with 117 additions and 90 deletions
+3 -3
View File
@@ -12,7 +12,7 @@ isReleased()
pressedFor(timeout)
wasPressed(callback=None)
wasPressed(callback=None)
wasReleased(callback=None)
releasedFor(timeout, callback=None)
@@ -33,7 +33,7 @@ Usage
spi = SPI(1, baudrate=32000000, mosi=Pin(23), miso=Pin(19), sck=Pin(18))
lcd = LCD(spi = spi) #lcd init
while True:
if buttonA.wasPressed():
lcd.print('Button A was Pressed\n')
@@ -54,7 +54,7 @@ Usage
#Button Callback
from m5stack import *
from m5stack import *
def on_wasPressed():
lcd.print('Button B was Pressed\n')
+71 -59
View File
@@ -7,18 +7,19 @@ Function
---------
lcd.setbrightness(uint8_t brightness)
>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
lcd.setRotation(degree)
>>>>>>>>>>>>>>>>>>>>>>>
| **Description:**
| **Description:**
| set the angle of rotation of the entire screen
| **Parament:**
| **Parament:**
| **degree:** the angle of rotation
| **Example:**
.. code:: python
#The M5Stack Core LCD has been initialized
@@ -32,27 +33,29 @@ lcd.setColor(color [, background\_color])
| **Parament:**
| **color:** the color of text
| **background\_color:** the fill color of text
| **background\_color:** the fill color of text
| **Example:**
.. code:: python
#The M5Stack Core LCD has been initialized
lcd.setColor(lcd.RED)
lcd.setColor(lcd.ORANGE, LCD.DARKCYAN)
lcd.setColor(lcd.RED)
lcd.setColor(lcd.ORANGE, LCD.DARKCYAN)
lcd.setTextColor(color [,background\_color])
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
| **Description:**   
| This function is as same as *setColor(color [, background\_color])*
| This function is as same as *setColor(color [, background\_color])*
| **Example:**
.. code:: python
#The M5Stack Core LCD has been initialized
lcd.setTextColor(lcd.PINK)
lcd.setTextColor(lcd.ORANGE, LCD.DARKCYAN)
lcd.setTextColor(lcd.PINK)
lcd.setTextColor(lcd.ORANGE, LCD.DARKCYAN)
lcd.fillScreen(color)
>>>>>>>>>>>>>>>>>>>>>>>
@@ -60,10 +63,11 @@ lcd.fillScreen(color)
| **Description:**   
| Fill the entire screen with the given color
| **Parament:**
| **color:** color values
| **Parament:**
| **color:** color values
| **Example:**
.. code:: python
#The M5Stack Core LCD has been initialized
@@ -73,14 +77,15 @@ lcd.drawPixel(x, y [,color])
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
| **Description:**   
| Draw the pixel at position **(x,y)**
| Draw the pixel at position **(x,y)**
| *Note:*
| *If color is not given, current foreground color is used*
| **Parament:**
| **color** color values
| **Parament:**
| **color** color values
| **Example:**
.. code:: python
#The M5Stack Core LCD has been initialized
@@ -90,31 +95,33 @@ lcd.drawLine(x, y, x1, y1 [,color])
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
| **Description:**   
| Draw the line from point **(x,y)** to point **(x1,y1)**
| *Note:*
| Draw the line from point **(x,y)** to point **(x1,y1)**
| *Note:*
| *If color is not given, current foreground color is used*
| **Parament:**
| **color** color values
| **Parament:**
| **color** color values
| **Example:**
.. code:: python
#The M5Stack Core LCD has been initialized
lcd.drawLine(0,0,12,12,lcd.WHITE) 
lcd.drawLine(0,0,12,12,lcd.WHITE) 
lcd.drawTriangle(x, y, x1, y1, x2, y2 [,color])
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
| **Description:**   
| Draw the triangel between points **(x,y)**, **(x1,y1)** and **(x2,y2)**
| Draw the triangel between points **(x,y)**, **(x1,y1)** and **(x2,y2)**
| *Note:*   
| If color is not given, current foreground color is used
 
| **Parament:**
| **color:** color values
| If color is not given, current foreground color is used
 
| **Parament:**
| **color:** color values
| **Example:**
.. code:: python
#The M5Stack Core LCD has been initialized
@@ -124,7 +131,7 @@ lcd.fillTriangle(x, y, x1, y1, x2, y2 [,color])
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
| **Description:**   
| Fill the triangel between points **(x,y)**, **(x1,y1)** and **(x2,y2)**
| Fill the triangel between points **(x,y)**, **(x1,y1)** and **(x2,y2)**
| *Note:*   
| *If color is not given, triangle will be filled in current foreground color*
@@ -132,6 +139,7 @@ lcd.fillTriangle(x, y, x1, y1, x2, y2 [,color])
| **color** color values
| **Example:**
.. code:: python
#The M5Stack Core LCD has been initialized
@@ -140,13 +148,13 @@ lcd.fillTriangle(x, y, x1, y1, x2, y2 [,color])
lcd.drawCircle(x, y, r [,color])
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
| **Description:***   
| Draw the circle with center at **(x,y)** and radius **r**
| Draw the circle with center at **(x,y)** and radius **r**
| *Note:*   
| *If color is not given, current foreground color is used*
| **Parament:**
| **r:** the radius of circle
| **color:** color values
| **r:** the radius of circle
| **color:** color values
| **Example:**
@@ -159,34 +167,36 @@ lcd.fillCircle(x, y, r [,color])
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
| **Description:**   
| Fill the circle with center at **(x,y)** and radius **r**
| Fill the circle with center at **(x,y)** and radius **r**
| *Note:*   
| *If color is not given, current foregroundcolor will be used*
| **Parament:**
| **r:** the radius of circle
| **color:** color values
| **r:** the radius of circle
| **color:** color values
| **Example:**
.. code:: python
#The M5Stack Core LCD has been initialized
lcd.fillcircle(100, 100, 10, lcd.BLUE) 
lcd.fillcircle(100, 100, 10, lcd.BLUE) 
lcd.drawRect(x, y, w, h, [,color])
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
| **Description:**   
| Draw the rectangle from the upper left point at **(x,y)** and **width** and **height**
| Draw the rectangle from the upper left point at **(x,y)** and **width** and **height**
| *Note:*   
| *If color is not given, rectangle will be drawn in current foreground color*
| **Parament:**
| **w:** display phisical width in pixels (display's smaller dimension)
| **h:** display phisical height in pixels (display's larger dimension)
| **color:** optional, color values
| **color:** optional, color values
| **Example:**
.. code:: python
#The M5Stack Core LCD has been initialized
@@ -196,14 +206,14 @@ lcd.fillRect(x, y, w, h, [,color])
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
| **Description:**   
| Fill the rectangle from the upper left point at **(x,y)** and **width** and **height**
| Fill the rectangle from the upper left point at **(x,y)** and **width** and **height**
| *Note:*   
| *If fillcolor is not given, rectangle will be filled in current foreground color*
| *If fillcolor is not given, rectangle will be filled in current foreground color*
| **Parament:**
| **w:** display phisical width in pixels (display's smaller dimension)
| **h:** display phisical height in pixels (display's larger dimension)
| **color:** optional, color values
| **h:** display phisical height in pixels (display's larger dimension)
| **color:** optional, color values
| **Example:**
@@ -216,15 +226,15 @@ lcd.drawRoundRect(x, y, w, h, r [,color])
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
| **Description:**   
| Draw the rectangle with rounded corners from the upper left point at **(x,y)** and **width** and **height**. Corner radius is given by **r** argument
| Draw the rectangle with rounded corners from the upper left point at **(x,y)** and **width** and **height**. Corner radius is given by **r** argument
| *Note:*   
| *If *color* is not given, current foreground color will be used*
| *If *color* is not given, current foreground color will be used*
| **Parament:**
| **w:** display phisical width in pixels (display's smaller dimension)
| **h:** display phisical height in pixels (display's larger dimension)
| **r:** the radius of circle
| **color:** optional, color values
| **w:** display phisical width in pixels (display's smaller dimension)
| **h:** display phisical height in pixels (display's larger dimension)
| **r:** the radius of circle
| **color:** optional, color values
| **Example:**
@@ -237,17 +247,18 @@ lcd.fillRoundRect(x, y, w, h, r [,color])
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
| **Description:**   
| Fill the rectangle with rounded corners from the upper left point at **(x,y)** and **width** and **height**. Corner radius is given by **r** argument
| Fill the rectangle with rounded corners from the upper left point at **(x,y)** and **width** and **height**. Corner radius is given by **r** argument
| *Note:*   
| If **color** is not given, current foreground color will be used
| If **color** is not given, current foreground color will be used
| **Parament:**
| **w:** display phisical width in pixel (display's smaller dimension)
| **w:** display phisical width in pixel (display's smaller dimension)
| **h:** display phisical height in pixels (display's larger dimension)
| **r:** the radius of circle
| **color:** optional, color values
| **r:** the radius of circle
| **color:** optional, color values
| **Example:**
.. code:: python
#The M5Stack Core LCD has been initialized
@@ -263,6 +274,7 @@ lcd.print('text', [x, y])
| **text:** the string need to print
| **Example:**
.. code:: python
#The M5Stack Core LCD has been initialized
@@ -272,12 +284,13 @@ lcd.clear([color])
>>>>>>>>>>>>>>>>>>>>>>
| **Description:**   
| Clear the screen with default background color orspecific color if given
| Clear the screen with default background color orspecific color if given
| **Parament:**
| **Parament:**
| **color:** optional, color values
| **Example:**
.. code:: python
#The M5Stack Core LCD has been initialized
@@ -298,14 +311,13 @@ Usage
lcd = LCD(spi = spi) #lcd init
lcd.fillScreen(lcd.BLACK) #set the default background color
lcd.drawLine(0, 0, lcd.WHITE)
lcd.drawLine(0, 0, lcd.WHITE)
lcd.drawTriangle(22, 22, 69, 98, 51, 22, lcd.RED)
lcd.fillTriangle(122, 122, 169, 198, 151, 182, lcd.RED)
lcd.drawCircle(180, 180, 10, lcd.BLUE)
lcd.fillcircle(100, 100, 10, lcd.BLUE)
lcd.drawCircle(180, 180, 10, lcd.BLUE)
lcd.fillcircle(100, 100, 10, lcd.BLUE)
lcd.drawRect(180, 12, 122, 10, lcd.BLUE)
lcd.fillRect(180, 30, 122, 10, lcd.BLUE)
lcd.drawRoundRect(180, 50, 122, 10, 4, lcd.BLUE)
lcd.fillRoundRect(180, 70, 122, 10, 4, lcd.BLUE)
lcd.print('this is a print text function', 80, 80)
lcd.fillRect(180, 30, 122, 10, lcd.BLUE)
lcd.drawRoundRect(180, 50, 122, 10, 4, lcd.BLUE)
lcd.fillRoundRect(180, 70, 122, 10, 4, lcd.BLUE)
lcd.print('this is a print text function', 80, 80)
+3 -1
View File
@@ -27,6 +27,7 @@ machine.ADC(pin [,unit=1])
| **unit:** Optional unit argument select ESP32 ADC unit for this instance. Values 1 (ADC1, default) or 2 (ADC2) can be selected
| **Example:**
.. code:: python
import machine
@@ -38,12 +39,13 @@ read()
| **Description:**   
| Read the ADC value as voltage (in mV)
|
|
| **Parament:**
| None Parament
| **Example:**
.. code:: python
import machine
+4 -2
View File
@@ -23,12 +23,13 @@ machine.DAC(pin)
| **Description:**   
| Pin argument defines the gpio which will will be used as dac output
| *Note: Only GPIOs 25 and 26 can be used as DAC outputs*
|
|
| **Parament:**
| **pin:** The pin argument can be given as pin number (integer) or the machine.Pin object
| **Example:**
.. code:: python
import machine
@@ -42,12 +43,13 @@ write(value)
| **Description:**   
| Set the DAC value
| *Note: The value of 255 sets the voltage on dac pin to 3.3 V
|
|
| **Parament:**
| **value:** DAC vaule.Valid range is: 0 - 255
| **Example:**
.. code:: python
import machine
+3 -2
View File
@@ -42,19 +42,20 @@ setHSB(pos, hue, saturation, brightness [, white, num, update] ))
| **Parament:**
| **pos:** required, pixel position; 1 ~ pix_num
| **hue:** float: any number, the floor of this number is subtracted from it
| **hue:** float: any number, the floor of this number is subtracted from it
| to create a fraction between 0 and 1.
| This fractional number is then multiplied by 360 to produce the hue angle in the HSB color model
| **saturation:** float; 0 ~ 1.0
| **brightness:** float; 0 ~ 1.0
| **num:** optional; default: 1; number of pixels to set to the same color, starting from pos
| **update:** optional, default: True; update the Neopixel strip.
| **update:** optional, default: True; update the Neopixel strip.
| *Note: If False np.show() has to be used to update the strip*
| **Return:**
| None
| **Example:**
.. code:: python
import machine, time
+3 -3
View File
@@ -44,13 +44,13 @@ now()
| get the current time
| **Parament:**
| **None**
| **None**
| **Return:**
| Return the current time as tuple: `(year, month, day, hour, minute, second)`
ntp_sync(server [,update_period] [,tz])
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
| **Description:**   
| Write bytes from buffer object buf to the RTC device
@@ -81,7 +81,7 @@ synced()
| Sync the system time from NTP server
| **Parament:**
| **None:**
| **None:**
| **Return:**
| Return `True` if the system time was synced from NTP server, `False` if not
+15 -12
View File
@@ -31,16 +31,17 @@ machine.spi(spihost, baudrate, polarity, phase, firstbit, sck, mosi, miso, cs, d
| **baudrate:** SPI clock speed in Hz; Default: 1000000
| **Example:**
.. code:: python
from machine import SPI, Pin
spi = SPI(
spihost=SPI.HSPI,
spihost=SPI.HSPI,
baudrate=2600000
sck=Pin(18),
mosi=Pin(23),
miso=Pin(19),
sck=Pin(18),
mosi=Pin(23),
miso=Pin(19),
cs=Pin(4)
)
@@ -57,16 +58,17 @@ write(buf)
| Returns `True` on success, `False` ion error
| **Example:**
.. code:: python
from machine import SPI, Pin
spi = SPI(
spihost=SPI.HSPI,
spihost=SPI.HSPI,
baudrate=2600000
sck=Pin(18),
mosi=Pin(23),
miso=Pin(19),
sck=Pin(18),
mosi=Pin(23),
miso=Pin(19),
cs=Pin(4)
)
@@ -88,6 +90,7 @@ write_readinto(wr_buf, rd_buf)
| Returns `True` on success, `False` ion error
| **Example:**
.. code:: python
import machine
@@ -106,11 +109,11 @@ Usage
from machine import SPI, Pin
spi = SPI(
spihost=SPI.HSPI,
spihost=SPI.HSPI,
baudrate=2600000
sck=Pin(18),
mosi=Pin(23),
miso=Pin(19),
sck=Pin(18),
mosi=Pin(23),
miso=Pin(19),
cs=Pin(4)
)
+10 -7
View File
@@ -6,7 +6,7 @@ Timer API
Description
------------
The ESP32 chip contains two hardware timer groups. Each group has two general-purpose hardware timers. They are all 64-bit generic timers based on 16-bit prescalers and 64-bit auto-reload-capable up / down counters.
The ESP32 chip contains two hardware timer groups. Each group has two general-purpose hardware timers. They are all 64-bit generic timers based on 16-bit prescalers and 64-bit auto-reload-capable up / down counters.
*Note: Due to MicroPython callback latency, some callbacks may not be executed if the timer period is less than 15 ms.
The number of events and executed callbacks can be checked using tm.events() method.*
@@ -26,6 +26,7 @@ machine.Timer(timer_no)
| **timer_no:** the timer number to be used for the timer
| **Example:**
.. code:: python
import machine
@@ -36,7 +37,7 @@ init(period, mode, callback, dbgpin)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
| **Description:**   
| initialize paraments of the timer
| initialize paraments of the timer
| **Parament:**
| **period:** Timer period(Default: 10 ms)
@@ -44,22 +45,23 @@ init(period, mode, callback, dbgpin)
| **mode:** Timer mode of operation(Default: PERIODIC)
| **callback:** The Python callback function to be executed on timer event(Default: None)
| **dbgpin:** GPIO pin to be used as debug output(Default: -1 (not used))
| *Note: If used, the gpio level will toggle on each timer event*
| *Note: If used, the gpio level will toggle on each timer event*
| **Return:**
| None
| **Example:**
.. code:: python
from machine import SPI, Pin
spi = SPI(
spihost=SPI.HSPI,
spihost=SPI.HSPI,
baudrate=2600000
sck=Pin(18),
mosi=Pin(23),
miso=Pin(19),
sck=Pin(18),
mosi=Pin(23),
miso=Pin(19),
cs=Pin(4)
)
@@ -75,6 +77,7 @@ value()
| Returns the current timer counter value in **µs** if timer mode is CHRONO or in **ms** for other modes
| **Example:**
.. code:: python
import machine
+5 -1
View File
@@ -29,10 +29,11 @@ machine.UART(uart_num, tx=pin, rx=pin [,args])
| **Example:**
.. code:: python
from machine import UART
uart2 = UART(2, tx=17, rx=16)
uart2.init(115200, bits=8, parity=None, stop=1)
@@ -48,6 +49,7 @@ write(buf [, len [, off]])
| **off:** starts writting from `off` position in `buf`
| **Example:**
.. code:: python
from machine import UART
@@ -63,6 +65,7 @@ read()
| read all available characters
| **Example:**
.. code:: python
from machine import UART
@@ -81,6 +84,7 @@ readline([max_len])
| **max_len:** maximum length to be read
| **Example:**
.. code:: python
from machine import UART