|
def | __init__ (self, port) |
|
def | __del__ (self) |
|
def | init (self) |
| Initializes the badge to a valid state. More...
|
|
def | uart_transfer (self, data) |
| Transfers data over UART. More...
|
|
def | lcd_clear (self) |
| Clears the display buffer. More...
|
|
def | lcd_refresh (self) |
| Redraws the display buffer. More...
|
|
def | lcd_pixel (self, x, y, color) |
| Draws a pixel in the display buffer. More...
|
|
def | lcd_text (self, row, col, text) |
| Draws a text in the display buffer. More...
|
|
def | led_set (self, led, state) |
| Turns on/off an LED. More...
|
|
def | led_blink (self, led, period) |
| Keeps blinking an LED. More...
|
|
def | buttons (self) |
| Returns the button state. More...
|
|
def | i2c_set_clock_khz (self, clock_khz) |
| Reconfigures I2C clock frequency. More...
|
|
def | i2c_read (self, dev_addr, reg_addr, length) |
| Reads registers over I2C. More...
|
|
def | i2c_write (self, dev_addr, reg_addr, data) |
| Writes registers over I2C. More...
|
|
def | spi_config (self, clock_khz, mode) |
| Configures the SPI peripheral. More...
|
|
def | spi_transfer (self, data_in) |
| Transfers data over SPI. More...
|
|
|
int | LED1 = 0 |
|
int | LED2 = 1 |
|
int | BUT_RIGHT = 1 |
|
int | BUT_LEFT = 2 |
|
int | BUT_DOWN = 4 |
|
int | BUT_UP = 8 |
|
int | BLACK = 0 |
|
int | WHITE = 1 |
|
int | LCD_WIDTH = 128 |
|
int | LCD_HEIGHT = 64 |
|
◆ buttons()
def kicon_badge.KiconBadge.buttons |
( |
|
self | ) |
|
Returns the button state.
Note that it is impossible to read 'left' button state, as it quits the command interface mode.
- Returns
- Number indicating pressed buttons (BUT_RIGHT, BUT_DOWN, BUT_UP).
◆ i2c_read()
def kicon_badge.KiconBadge.i2c_read |
( |
|
self, |
|
|
|
dev_addr, |
|
|
|
reg_addr, |
|
|
|
length |
|
) |
| |
Reads registers over I2C.
- Parameters
-
dev_addr | is the 7-bit device address. |
reg_addr | is the register address. |
length | is number of bytes to read. |
- Returns
- Registers contents.
◆ i2c_set_clock_khz()
def kicon_badge.KiconBadge.i2c_set_clock_khz |
( |
|
self, |
|
|
|
clock_khz |
|
) |
| |
Reconfigures I2C clock frequency.
The default I2C clock frequency is 100 kHz. It does not affect the clock for the display data transfers (400 kHz).
- Parameters
-
clock_khz | is the requested clock frequency [kHz, 1-400]. |
◆ i2c_write()
def kicon_badge.KiconBadge.i2c_write |
( |
|
self, |
|
|
|
dev_addr, |
|
|
|
reg_addr, |
|
|
|
data |
|
) |
| |
Writes registers over I2C.
- Parameters
-
dev_addr | is the 7-bit device address. |
reg_addr | is the register address. |
data | are the bytes to be written. |
◆ init()
def kicon_badge.KiconBadge.init |
( |
|
self | ) |
|
Initializes the badge to a valid state.
Should be called whenever the badge state is unknown.
◆ lcd_clear()
def kicon_badge.KiconBadge.lcd_clear |
( |
|
self | ) |
|
Clears the display buffer.
◆ lcd_pixel()
def kicon_badge.KiconBadge.lcd_pixel |
( |
|
self, |
|
|
|
x, |
|
|
|
y, |
|
|
|
color |
|
) |
| |
Draws a pixel in the display buffer.
- Parameters
-
x | is the horizontal coordinate (0-127). |
y | is the vertical coordinate (0-63). |
color | is the pixel color (BLACK [0] or WHITE [1]). |
◆ lcd_refresh()
def kicon_badge.KiconBadge.lcd_refresh |
( |
|
self | ) |
|
Redraws the display buffer.
◆ lcd_text()
def kicon_badge.KiconBadge.lcd_text |
( |
|
self, |
|
|
|
row, |
|
|
|
col, |
|
|
|
text |
|
) |
| |
Draws a text in the display buffer.
- Parameters
-
row | is the row number (0-7). |
col | is the column number (0-63). |
text | is the string to be drawn. |
◆ led_blink()
def kicon_badge.KiconBadge.led_blink |
( |
|
self, |
|
|
|
led, |
|
|
|
period |
|
) |
| |
Keeps blinking an LED.
- Parameters
-
led | is the LED number (LED1 [0] or LED2 [1]). |
period | is the blinking period. |
◆ led_set()
def kicon_badge.KiconBadge.led_set |
( |
|
self, |
|
|
|
led, |
|
|
|
state |
|
) |
| |
Turns on/off an LED.
- Parameters
-
led | is the LED number (LED1 [0] or LED2 [1]). |
state | is the requested LED state (0 - off, 1 - on). |
◆ spi_config()
def kicon_badge.KiconBadge.spi_config |
( |
|
self, |
|
|
|
clock_khz, |
|
|
|
mode |
|
) |
| |
Configures the SPI peripheral.
- Parameters
-
clock_khz | is the clock frequency [1-60000 kHz]. |
mode | is the SPI mode: 0: capture data on rising clock edge, shift data on falling clock edge, inactive clock low 1: capture data on falling clock edge, shift data on rising clock edge, inactive clock low 2: capture data on falling clock edge, shift data on rising clock edge, inactive clock high 3: capture data on rising clock edge, shift data on falling clock edge, inactive clock high |
◆ spi_transfer()
def kicon_badge.KiconBadge.spi_transfer |
( |
|
self, |
|
|
|
data_in |
|
) |
| |
Transfers data over SPI.
Uses PB14 (DAC1) as the active-low chip select.
- Parameters
-
data_in | are the bytes to be transferred. |
returns | received data. |
◆ uart_transfer()
def kicon_badge.KiconBadge.uart_transfer |
( |
|
self, |
|
|
|
data |
|
) |
| |
Transfers data over UART.
- Parameters
-
- Returns
- Received data (if any).
The documentation for this class was generated from the following file: