Commit 34ab8dd6 authored by Damien George's avatar Damien George
Browse files

stmhal: Update and improve LCD driver.

Still some method names to iron out, and funtionality to add, but this
will do for the first, basic version.
parent 0294661d
This diff is collapsed.
......@@ -24,6 +24,4 @@
* THE SOFTWARE.
*/
void lcd_init(void);
void lcd_print_str(const char *str);
void lcd_print_strn(const char *str, unsigned int len);
extern const mp_obj_type_t pyb_lcd_type;
......@@ -58,7 +58,6 @@
#include "storage.h"
#include "sdcard.h"
#include "ff.h"
#include "lcd.h"
#include "rng.h"
#include "accel.h"
#include "servo.h"
......@@ -95,10 +94,6 @@ void __fatal_error(const char *msg) {
led_state(4, 1);
stdout_tx_strn("\nFATAL ERROR:\n", 14);
stdout_tx_strn(msg, strlen(msg));
#if 0 && MICROPY_HW_HAS_LCD
lcd_print_strn("\nFATAL ERROR:\n", 14);
lcd_print_strn(msg, strlen(msg));
#endif
for (uint i = 0;;) {
led_toggle(((i++) & 3) + 1);
for (volatile uint delay = 0; delay < 10000000; delay++) {
......@@ -333,11 +328,6 @@ soft_reset:
pin_init();
extint_init();
#if MICROPY_HW_HAS_LCD
// LCD init (just creates class, init hardware by calling LCD())
lcd_init();
#endif
// local filesystem init
{
// try to mount the flash
......
......@@ -54,6 +54,7 @@
#include "accel.h"
#include "servo.h"
#include "dac.h"
#include "lcd.h"
#include "usb.h"
#include "ff.h"
#include "portmodules.h"
......@@ -390,6 +391,10 @@ STATIC const mp_map_elem_t pyb_module_globals_table[] = {
#if MICROPY_HW_HAS_MMA7660
{ MP_OBJ_NEW_QSTR(MP_QSTR_Accel), (mp_obj_t)&pyb_accel_type },
#endif
#if MICROPY_HW_HAS_LCD
{ MP_OBJ_NEW_QSTR(MP_QSTR_LCD), (mp_obj_t)&pyb_lcd_type },
#endif
};
STATIC const mp_obj_dict_t pyb_module_globals = {
......
......@@ -196,23 +196,13 @@ int pfenv_printf(const pfenv_t *pfenv, const char *fmt, va_list args) {
}
void stdout_print_strn(void *data, const char *str, unsigned int len) {
// send stdout to UART, USB CDC VCP, and LCD if nothing else
bool any = false;
// TODO this needs to be replaced with a proper stdio interface ala CPython
// send stdout to UART and USB CDC VCP
if (pyb_uart_global_debug != PYB_UART_NONE) {
uart_tx_strn_cooked(pyb_uart_global_debug, str, len);
any = true;
}
if (usb_vcp_is_enabled()) {
usb_vcp_send_strn_cooked(str, len);
any = true;
}
if (!any) {
#if 0
#if MICROPY_HW_HAS_LCD
lcd_print_strn(str, len);
#endif
#endif
}
}
......
......@@ -38,11 +38,14 @@
#include "usb.h"
#include "uart.h"
// TODO make stdin, stdout and stderr writable objects so they can
// be changed by Python code.
void stdout_tx_str(const char *str) {
if (pyb_uart_global_debug != PYB_UART_NONE) {
uart_tx_str(pyb_uart_global_debug, str);
}
#if defined(USE_HOST_MODE) && MICROPY_HW_HAS_LCD
#if 0 && defined(USE_HOST_MODE) && MICROPY_HW_HAS_LCD
lcd_print_str(str);
#endif
usb_vcp_send_str(str);
......@@ -52,7 +55,7 @@ void stdout_tx_strn(const char *str, uint len) {
if (pyb_uart_global_debug != PYB_UART_NONE) {
uart_tx_strn(pyb_uart_global_debug, str, len);
}
#if defined(USE_HOST_MODE) && MICROPY_HW_HAS_LCD
#if 0 && defined(USE_HOST_MODE) && MICROPY_HW_HAS_LCD
lcd_print_strn(str, len);
#endif
usb_vcp_send_strn(str, len);
......
......@@ -57,7 +57,6 @@ Q(have_cdc)
Q(hid)
Q(time)
Q(rng)
Q(LCD)
Q(SD)
Q(SDcard)
Q(FileIO)
......@@ -247,6 +246,17 @@ Q(sleep)
// for input
Q(input)
// for LCD class
Q(LCD)
Q(command)
Q(contrast)
Q(light)
Q(fill)
Q(get)
Q(pixel)
Q(text)
Q(show)
// for stm module
Q(stm)
Q(mem)
......
......@@ -199,7 +199,6 @@ void USR_KEYBRD_ProcessData(uint8_t pbuf) {
led_state(4, 1);
USB_OTG_BSP_mDelay(50);
led_state(4, 0);
//lcd_print_strn((char*)&pbuf, 1);
usb_keyboard_key = pbuf;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment