russhughes / st7789_mpy

Fast MicroPython driver for ST7789 display module written in C
Other
552 stars 110 forks source link

build for port STM32L496G-DISC #52

Closed patfrench closed 2 years ago

patfrench commented 2 years ago

Hi,

When i build in : cd micropython/ports/stm32 make USER_C_MODULES=../../../st7789_mpy/st7789/micropython.cmake

I have a pyboard by default. how to do the same for the board STM32L496G-DISC ?

Happy new year update

make BOARD=PYBV11 USER_C_MODULES=/home/pat/Documents/st7789_mpy/
Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.
Including User C Module from /home/pat/Documents/st7789_mpy//st7789
mkdir -p build-PYBV11/genhdr
GEN build-PYBV11/genhdr/pins.h
GEN stmconst build-PYBV11/modstm_qstr.h

but i have an error compilation

/home/pat/Documents/st7789_mpy/st7789/st7789.c: In function 'RotatePolygon':
/home/pat/Documents/st7789_mpy/st7789/st7789.c:1687:24: error: conversion from 'double' to 'mp_float_t' {aka 'float'} may change value [-Werror=float-conversion]
 1687 |  mp_float_t cosAngle = cos(angle);
      |                        ^~~
/home/pat/Documents/st7789_mpy/st7789/st7789.c:1688:24: error: conversion from 'double' to 'mp_float_t' {aka 'float'} may change value [-Werror=float-conversion]
 1688 |  mp_float_t sinAngle = sin(angle);
      |                        ^~~
cc1: all warnings being treated as errors
make: *** [../../py/mkrules.mk:77: build-STM32L496GDISC/st7789/st7789.o] Error 1

Thank you

russhughes commented 2 years ago

The math library uses doubles for sin and cos. I'll see what I can do to fix this, until then, you can get around the error by changing sin and cos to sinf and cosf if they are supported. Failing that you should be able to cast the results of sin and cos to floats.

mp_float_t cosAngle = cosf(angle);
mp_float_t sinAngle = sinf(angle);

or possibly:

mp_float_t cosAngle = (mp_float_t) cos(angle);
mp_float_t sinAngle = (mp_float_t) sin(angle);

Russ

patfrench commented 2 years ago

Hi,

I have modified :

mp_float_t cosAngle = cosf(angle);
mp_float_t sinAngle = sinf(angle);

perfect ! It's works

I don't know if it closes

Thank you for your support

russhughes commented 2 years ago

Excellent, I have updated the source.