2020-02-03 19:46:14 -05:00
/*
* This file is part of the MicroPython project , http : //micropython.org/
*
* The MIT License ( MIT )
*
2020-02-07 20:10:19 -05:00
* Copyright ( c ) 2020 James Bowman for Excamera Labs
2020-02-03 19:46:14 -05:00
*
* Permission is hereby granted , free of charge , to any person obtaining a copy
* of this software and associated documentation files ( the " Software " ) , to deal
* in the Software without restriction , including without limitation the rights
* to use , copy , modify , merge , publish , distribute , sublicense , and / or sell
* copies of the Software , and to permit persons to whom the Software is
* furnished to do so , subject to the following conditions :
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software .
*
* THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR
* IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY ,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER
* LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM ,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE .
*/
# include <stdio.h>
# include <assert.h>
# include <string.h>
# include "py/runtime.h"
# include "py/binary.h"
2020-02-07 13:30:49 -05:00
# include "shared-module/_eve/__init__.h"
2020-02-07 20:10:19 -05:00
# include "shared-bindings/_eve/__init__.h"
2020-02-07 13:30:49 -05:00
2020-05-12 20:15:28 -04:00
//| """Low-level BridgeTek EVE bindings
2020-02-03 21:41:32 -05:00
//|
2020-02-05 21:17:58 -05:00
//| The `_eve` module provides a class _EVE which
2020-05-12 20:15:28 -04:00
//| contains methods for constructing EVE command
2020-05-07 11:56:46 -04:00
//| buffers and appending basic graphics commands."""
2020-02-03 21:41:32 -05:00
//|
2020-08-03 00:35:43 -04:00
//| class _EVE:
2022-09-27 13:31:26 -04:00
//| def __init__(self) -> None:
//| """Create an _EVE object"""
2020-02-05 21:17:58 -05:00
typedef struct _mp_obj__EVE_t {
2020-02-03 19:46:14 -05:00
mp_obj_base_t base ;
2020-02-07 13:30:49 -05:00
common_hal__eve_t _eve ;
2020-02-05 21:17:58 -05:00
} mp_obj__EVE_t ;
2020-02-03 19:46:14 -05:00
2020-02-05 21:17:58 -05:00
STATIC const mp_obj_type_t _EVE_type ;
2020-02-05 20:58:59 -05:00
2020-02-07 13:30:49 -05:00
# define EVEHAL(s) \
2021-05-05 20:51:52 -04:00
( & ( ( mp_obj__EVE_t * ) mp_obj_cast_to_native_base ( ( s ) , & _EVE_type ) ) - > _eve )
2020-02-03 19:46:14 -05:00
2022-09-27 16:21:42 -04:00
//| def register(self, o: object) -> None: ...
2020-02-03 19:46:14 -05:00
STATIC mp_obj_t _register ( mp_obj_t self , mp_obj_t o ) {
2020-02-07 13:30:49 -05:00
common_hal__eve_t * eve = EVEHAL ( self ) ;
mp_load_method ( o , MP_QSTR_write , eve - > dest ) ;
2020-02-03 19:46:14 -05:00
return mp_const_none ;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2 ( register_obj , _register ) ;
2020-08-03 00:35:43 -04:00
//| def flush(self) -> None:
//| """Send any queued drawing commands directly to the hardware.
2020-02-07 19:44:48 -05:00
//|
2020-08-03 00:35:43 -04:00
//| :param int width: The width of the grid in tiles, or 1 for sprites."""
//| ...
2020-02-03 19:46:14 -05:00
STATIC mp_obj_t _flush ( mp_obj_t self ) {
2020-02-07 13:30:49 -05:00
common_hal__eve_flush ( EVEHAL ( self ) ) ;
2020-02-03 19:46:14 -05:00
return mp_const_none ;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1 ( flush_obj , _flush ) ;
2020-08-03 00:35:43 -04:00
//| def cc(self, b: ReadableBuffer) -> None:
//| """Append bytes to the command FIFO.
2020-02-07 19:44:48 -05:00
//|
2021-12-21 15:28:49 -05:00
//| :param ~circuitpython_typing.ReadableBuffer b: The bytes to add"""
2020-08-03 00:35:43 -04:00
//| ...
2020-02-03 19:46:14 -05:00
STATIC mp_obj_t _cc ( mp_obj_t self , mp_obj_t b ) {
mp_buffer_info_t buffer_info ;
mp_get_buffer_raise ( b , & buffer_info , MP_BUFFER_READ ) ;
2020-02-07 13:30:49 -05:00
common_hal__eve_add ( EVEHAL ( self ) , buffer_info . len , buffer_info . buf ) ;
2020-02-03 19:46:14 -05:00
return mp_const_none ;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2 ( cc_obj , _cc ) ;
2021-03-15 09:57:36 -04:00
// {
2020-02-03 19:46:14 -05:00
2020-08-03 00:35:43 -04:00
//| def AlphaFunc(self, func: int, ref: int) -> None:
//| """Set the alpha test function
2020-02-07 19:44:48 -05:00
//|
2020-08-03 00:35:43 -04:00
//| :param int func: specifies the test function, one of ``NEVER``, ``LESS``, ``LEQUAL``, ``GREATER``, ``GEQUAL``, ``EQUAL``, ``NOTEQUAL``, or ``ALWAYS``. Range 0-7. The initial value is ALWAYS(7)
//| :param int ref: specifies the reference value for the alpha test. Range 0-255. The initial value is 0
2020-02-07 19:44:48 -05:00
//|
2023-02-01 03:08:41 -05:00
//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.
//| """
2020-08-03 00:35:43 -04:00
//| ...
2020-02-03 19:46:14 -05:00
2020-02-07 19:44:48 -05:00
STATIC mp_obj_t _alphafunc ( mp_obj_t self , mp_obj_t a0 , mp_obj_t a1 ) {
2021-03-15 09:57:36 -04:00
uint32_t func = mp_obj_get_int_truncated ( a0 ) ;
uint32_t ref = mp_obj_get_int_truncated ( a1 ) ;
2020-02-07 19:44:48 -05:00
common_hal__eve_AlphaFunc ( EVEHAL ( self ) , func , ref ) ;
return mp_const_none ;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_3 ( alphafunc_obj , _alphafunc ) ;
2020-02-07 13:30:49 -05:00
2020-08-03 00:35:43 -04:00
//| def Begin(self, prim: int) -> None:
//| """Begin drawing a graphics primitive
2020-02-07 19:44:48 -05:00
//|
2020-08-03 00:35:43 -04:00
//| :param int prim: graphics primitive.
2020-02-07 19:44:48 -05:00
//|
2023-02-01 03:08:41 -05:00
//| Valid primitives are ``BITMAPS``, ``POINTS``, ``LINES``, ``LINE_STRIP``, ``EDGE_STRIP_R``, ``EDGE_STRIP_L``, ``EDGE_STRIP_A``, ``EDGE_STRIP_B`` and ``RECTS``.
//| """
2020-08-03 00:35:43 -04:00
//| ...
2020-02-07 19:44:48 -05:00
STATIC mp_obj_t _begin ( mp_obj_t self , mp_obj_t a0 ) {
2021-03-15 09:57:36 -04:00
uint32_t prim = mp_obj_get_int_truncated ( a0 ) ;
2020-02-07 19:44:48 -05:00
common_hal__eve_Begin ( EVEHAL ( self ) , prim ) ;
2020-02-03 19:46:14 -05:00
return mp_const_none ;
}
2020-02-07 19:44:48 -05:00
STATIC MP_DEFINE_CONST_FUN_OBJ_2 ( begin_obj , _begin ) ;
2020-08-03 00:35:43 -04:00
//| def BitmapExtFormat(self, format: int) -> None:
//| """Set the bitmap format
2020-02-07 19:44:48 -05:00
//|
2020-08-03 00:35:43 -04:00
//| :param int format: bitmap pixel format."""
//| ...
2020-02-07 19:44:48 -05:00
STATIC mp_obj_t _bitmapextformat ( mp_obj_t self , mp_obj_t a0 ) {
2021-03-15 09:57:36 -04:00
uint32_t fmt = mp_obj_get_int_truncated ( a0 ) ;
2020-02-07 19:44:48 -05:00
common_hal__eve_BitmapExtFormat ( EVEHAL ( self ) , fmt ) ;
return mp_const_none ;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2 ( bitmapextformat_obj , _bitmapextformat ) ;
2020-08-03 00:35:43 -04:00
//| def BitmapHandle(self, handle: int) -> None:
//| """Set the bitmap handle
2020-02-07 19:44:48 -05:00
//|
2020-08-03 00:35:43 -04:00
//| :param int handle: bitmap handle. Range 0-31. The initial value is 0
2020-02-07 19:44:48 -05:00
//|
2023-02-01 03:08:41 -05:00
//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.
//| """
2020-08-03 00:35:43 -04:00
//| ...
2020-02-07 19:44:48 -05:00
STATIC mp_obj_t _bitmaphandle ( mp_obj_t self , mp_obj_t a0 ) {
uint32_t handle = mp_obj_get_int_truncated ( a0 ) ;
common_hal__eve_BitmapHandle ( EVEHAL ( self ) , handle ) ;
return mp_const_none ;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2 ( bitmaphandle_obj , _bitmaphandle ) ;
2020-08-03 00:35:43 -04:00
//| def BitmapLayoutH(self, linestride: int, height: int) -> None:
//| """Set the source bitmap memory format and layout for the current handle. high bits for large bitmaps
2020-02-07 19:44:48 -05:00
//|
2020-08-03 00:35:43 -04:00
//| :param int linestride: high part of bitmap line stride, in bytes. Range 0-7
//| :param int height: high part of bitmap height, in lines. Range 0-3"""
//| ...
2020-02-07 19:44:48 -05:00
STATIC mp_obj_t _bitmaplayouth ( mp_obj_t self , mp_obj_t a0 , mp_obj_t a1 ) {
uint32_t linestride = mp_obj_get_int_truncated ( a0 ) ;
uint32_t height = mp_obj_get_int_truncated ( a1 ) ;
common_hal__eve_BitmapLayoutH ( EVEHAL ( self ) , linestride , height ) ;
return mp_const_none ;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_3 ( bitmaplayouth_obj , _bitmaplayouth ) ;
2020-08-03 00:35:43 -04:00
//| def BitmapLayout(self, format: int, linestride: int, height: int) -> None:
//| """Set the source bitmap memory format and layout for the current handle
2020-02-07 19:44:48 -05:00
//|
2020-08-03 00:35:43 -04:00
//| :param int format: bitmap pixel format, or GLFORMAT to use BITMAP_EXT_FORMAT instead. Range 0-31
//| :param int linestride: bitmap line stride, in bytes. Range 0-1023
//| :param int height: bitmap height, in lines. Range 0-511"""
//| ...
2020-02-07 19:44:48 -05:00
STATIC mp_obj_t _bitmaplayout ( size_t n_args , const mp_obj_t * args ) {
uint32_t format = mp_obj_get_int_truncated ( args [ 1 ] ) ;
uint32_t linestride = mp_obj_get_int_truncated ( args [ 2 ] ) ;
uint32_t height = mp_obj_get_int_truncated ( args [ 3 ] ) ;
common_hal__eve_BitmapLayout ( EVEHAL ( args [ 0 ] ) , format , linestride , height ) ;
return mp_const_none ;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN ( bitmaplayout_obj , 4 , 4 , _bitmaplayout ) ;
2020-08-03 00:35:43 -04:00
//| def BitmapSizeH(self, width: int, height: int) -> None:
//| """Set the screen drawing of bitmaps for the current handle. high bits for large bitmaps
2020-02-07 19:44:48 -05:00
//|
2020-08-03 00:35:43 -04:00
//| :param int width: high part of drawn bitmap width, in pixels. Range 0-3
//| :param int height: high part of drawn bitmap height, in pixels. Range 0-3"""
//| ...
2020-02-07 19:44:48 -05:00
STATIC mp_obj_t _bitmapsizeh ( mp_obj_t self , mp_obj_t a0 , mp_obj_t a1 ) {
2021-03-15 09:57:36 -04:00
uint32_t width = mp_obj_get_int_truncated ( a0 ) ;
2020-02-07 19:44:48 -05:00
uint32_t height = mp_obj_get_int_truncated ( a1 ) ;
common_hal__eve_BitmapSizeH ( EVEHAL ( self ) , width , height ) ;
return mp_const_none ;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_3 ( bitmapsizeh_obj , _bitmapsizeh ) ;
2020-08-03 00:35:43 -04:00
//| def BitmapSize(self, filter: int, wrapx: int, wrapy: int, width: int, height: int) -> None:
//| """Set the screen drawing of bitmaps for the current handle
2020-02-07 19:44:48 -05:00
//|
2020-08-03 00:35:43 -04:00
//| :param int filter: bitmap filtering mode, one of ``NEAREST`` or ``BILINEAR``. Range 0-1
//| :param int wrapx: bitmap :math:`x` wrap mode, one of ``REPEAT`` or ``BORDER``. Range 0-1
//| :param int wrapy: bitmap :math:`y` wrap mode, one of ``REPEAT`` or ``BORDER``. Range 0-1
//| :param int width: drawn bitmap width, in pixels. Range 0-511
//| :param int height: drawn bitmap height, in pixels. Range 0-511"""
//| ...
2020-02-07 19:44:48 -05:00
STATIC mp_obj_t _bitmapsize ( size_t n_args , const mp_obj_t * args ) {
uint32_t filter = mp_obj_get_int_truncated ( args [ 1 ] ) ;
2021-03-15 09:57:36 -04:00
uint32_t wrapx = mp_obj_get_int_truncated ( args [ 2 ] ) ;
uint32_t wrapy = mp_obj_get_int_truncated ( args [ 3 ] ) ;
uint32_t width = mp_obj_get_int_truncated ( args [ 4 ] ) ;
2020-02-07 19:44:48 -05:00
uint32_t height = mp_obj_get_int_truncated ( args [ 5 ] ) ;
common_hal__eve_BitmapSize ( EVEHAL ( args [ 0 ] ) , filter , wrapx , wrapy , width , height ) ;
return mp_const_none ;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN ( bitmapsize_obj , 6 , 6 , _bitmapsize ) ;
2020-08-03 00:35:43 -04:00
//| def BitmapSource(self, addr: int) -> None:
//| """Set the source address for bitmap graphics
2020-02-07 19:44:48 -05:00
//|
2023-02-01 03:08:41 -05:00
//| :param int addr: Bitmap start address, pixel-aligned. May be in SRAM or flash. Range 0-16777215
//| """
2020-08-03 00:35:43 -04:00
//| ...
2020-02-07 19:44:48 -05:00
STATIC mp_obj_t _bitmapsource ( mp_obj_t self , mp_obj_t a0 ) {
2021-03-15 09:57:36 -04:00
uint32_t addr = mp_obj_get_int_truncated ( a0 ) ;
2020-02-07 19:44:48 -05:00
common_hal__eve_BitmapSource ( EVEHAL ( self ) , addr ) ;
return mp_const_none ;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2 ( bitmapsource_obj , _bitmapsource ) ;
2020-08-03 00:35:43 -04:00
//| def BitmapSwizzle(self, r: int, g: int, b: int, a: int) -> None:
//| """Set the source for the r,g,b and a channels of a bitmap
2020-02-07 19:44:48 -05:00
//|
2020-08-03 00:35:43 -04:00
//| :param int r: red component source channel. Range 0-7
//| :param int g: green component source channel. Range 0-7
//| :param int b: blue component source channel. Range 0-7
//| :param int a: alpha component source channel. Range 0-7"""
//| ...
2020-02-07 19:44:48 -05:00
STATIC mp_obj_t _bitmapswizzle ( size_t n_args , const mp_obj_t * args ) {
2021-03-15 09:57:36 -04:00
uint32_t r = mp_obj_get_int_truncated ( args [ 1 ] ) ;
uint32_t g = mp_obj_get_int_truncated ( args [ 2 ] ) ;
uint32_t b = mp_obj_get_int_truncated ( args [ 3 ] ) ;
uint32_t a = mp_obj_get_int_truncated ( args [ 4 ] ) ;
2020-02-07 19:44:48 -05:00
common_hal__eve_BitmapSwizzle ( EVEHAL ( args [ 0 ] ) , r , g , b , a ) ;
return mp_const_none ;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN ( bitmapswizzle_obj , 5 , 5 , _bitmapswizzle ) ;
2020-08-03 00:35:43 -04:00
//| def BitmapTransformA(self, p: int, v: int) -> None:
//| """Set the :math:`a` component of the bitmap transform matrix
2020-02-07 19:44:48 -05:00
//|
2020-08-03 00:35:43 -04:00
//| :param int p: precision control: 0 is 8.8, 1 is 1.15. Range 0-1. The initial value is 0
//| :param int v: The :math:`a` component of the bitmap transform matrix, in signed 8.8 or 1.15 bit fixed-point form. Range 0-131071. The initial value is 256
2020-02-07 19:44:48 -05:00
//|
2020-08-03 00:35:43 -04:00
//| The initial value is **p** = 0, **v** = 256. This represents the value 1.0.
2020-02-10 22:34:38 -05:00
//|
2023-02-01 03:08:41 -05:00
//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.
//| """
2020-08-03 00:35:43 -04:00
//| ...
2020-02-07 19:44:48 -05:00
STATIC mp_obj_t _bitmaptransforma ( mp_obj_t self , mp_obj_t a0 , mp_obj_t a1 ) {
2021-03-15 09:57:36 -04:00
uint32_t p = mp_obj_get_int_truncated ( a0 ) ;
uint32_t v = mp_obj_get_int_truncated ( a1 ) ;
2020-02-10 22:34:38 -05:00
common_hal__eve_BitmapTransformA ( EVEHAL ( self ) , p , v ) ;
2020-02-07 19:44:48 -05:00
return mp_const_none ;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_3 ( bitmaptransforma_obj , _bitmaptransforma ) ;
2020-08-03 00:35:43 -04:00
//| def BitmapTransformB(self, p: int, v: int) -> None:
//| """Set the :math:`b` component of the bitmap transform matrix
2020-02-07 19:44:48 -05:00
//|
2020-08-03 00:35:43 -04:00
//| :param int p: precision control: 0 is 8.8, 1 is 1.15. Range 0-1. The initial value is 0
//| :param int v: The :math:`b` component of the bitmap transform matrix, in signed 8.8 or 1.15 bit fixed-point form. Range 0-131071. The initial value is 0
2020-02-07 19:44:48 -05:00
//|
2020-08-03 00:35:43 -04:00
//| The initial value is **p** = 0, **v** = 0. This represents the value 0.0.
2020-02-10 22:34:38 -05:00
//|
2023-02-01 03:08:41 -05:00
//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.
//| """
2020-08-03 00:35:43 -04:00
//| ...
2020-02-07 19:44:48 -05:00
STATIC mp_obj_t _bitmaptransformb ( mp_obj_t self , mp_obj_t a0 , mp_obj_t a1 ) {
2021-03-15 09:57:36 -04:00
uint32_t p = mp_obj_get_int_truncated ( a0 ) ;
uint32_t v = mp_obj_get_int_truncated ( a1 ) ;
2020-02-10 22:34:38 -05:00
common_hal__eve_BitmapTransformB ( EVEHAL ( self ) , p , v ) ;
2020-02-07 19:44:48 -05:00
return mp_const_none ;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_3 ( bitmaptransformb_obj , _bitmaptransformb ) ;
2020-08-03 00:35:43 -04:00
//| def BitmapTransformC(self, v: int) -> None:
//| """Set the :math:`c` component of the bitmap transform matrix
2020-02-07 19:44:48 -05:00
//|
2020-08-03 00:35:43 -04:00
//| :param int v: The :math:`c` component of the bitmap transform matrix, in signed 15.8 bit fixed-point form. Range 0-16777215. The initial value is 0
2020-02-07 19:44:48 -05:00
//|
2023-02-01 03:08:41 -05:00
//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.
//| """
2020-08-03 00:35:43 -04:00
//| ...
2020-02-07 19:44:48 -05:00
2020-02-10 22:34:38 -05:00
STATIC mp_obj_t _bitmaptransformc ( mp_obj_t self , mp_obj_t a0 ) {
2021-03-15 09:57:36 -04:00
uint32_t v = mp_obj_get_int_truncated ( a0 ) ;
2020-02-10 22:34:38 -05:00
common_hal__eve_BitmapTransformC ( EVEHAL ( self ) , v ) ;
2020-02-07 19:44:48 -05:00
return mp_const_none ;
}
2020-02-10 22:34:38 -05:00
STATIC MP_DEFINE_CONST_FUN_OBJ_2 ( bitmaptransformc_obj , _bitmaptransformc ) ;
2020-02-07 19:44:48 -05:00
2020-08-03 00:35:43 -04:00
//| def BitmapTransformD(self, p: int, v: int) -> None:
//| """Set the :math:`d` component of the bitmap transform matrix
2020-02-07 19:44:48 -05:00
//|
2020-08-03 00:35:43 -04:00
//| :param int p: precision control: 0 is 8.8, 1 is 1.15. Range 0-1. The initial value is 0
//| :param int v: The :math:`d` component of the bitmap transform matrix, in signed 8.8 or 1.15 bit fixed-point form. Range 0-131071. The initial value is 0
2020-02-07 19:44:48 -05:00
//|
2020-08-03 00:35:43 -04:00
//| The initial value is **p** = 0, **v** = 0. This represents the value 0.0.
2020-02-10 22:34:38 -05:00
//|
2023-02-01 03:08:41 -05:00
//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.
//| """
2020-08-03 00:35:43 -04:00
//| ...
2020-02-07 19:44:48 -05:00
STATIC mp_obj_t _bitmaptransformd ( mp_obj_t self , mp_obj_t a0 , mp_obj_t a1 ) {
2021-03-15 09:57:36 -04:00
uint32_t p = mp_obj_get_int_truncated ( a0 ) ;
uint32_t v = mp_obj_get_int_truncated ( a1 ) ;
2020-02-10 22:34:38 -05:00
common_hal__eve_BitmapTransformD ( EVEHAL ( self ) , p , v ) ;
2020-02-07 19:44:48 -05:00
return mp_const_none ;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_3 ( bitmaptransformd_obj , _bitmaptransformd ) ;
2020-08-03 00:35:43 -04:00
//| def BitmapTransformE(self, p: int, v: int) -> None:
//| """Set the :math:`e` component of the bitmap transform matrix
2020-02-07 19:44:48 -05:00
//|
2020-08-03 00:35:43 -04:00
//| :param int p: precision control: 0 is 8.8, 1 is 1.15. Range 0-1. The initial value is 0
//| :param int v: The :math:`e` component of the bitmap transform matrix, in signed 8.8 or 1.15 bit fixed-point form. Range 0-131071. The initial value is 256
2020-02-07 19:44:48 -05:00
//|
2020-08-03 00:35:43 -04:00
//| The initial value is **p** = 0, **v** = 256. This represents the value 1.0.
2020-02-10 22:34:38 -05:00
//|
2023-02-01 03:08:41 -05:00
//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.
//| """
2020-08-03 00:35:43 -04:00
//| ...
2020-02-07 19:44:48 -05:00
STATIC mp_obj_t _bitmaptransforme ( mp_obj_t self , mp_obj_t a0 , mp_obj_t a1 ) {
2021-03-15 09:57:36 -04:00
uint32_t p = mp_obj_get_int_truncated ( a0 ) ;
uint32_t v = mp_obj_get_int_truncated ( a1 ) ;
2020-02-10 22:34:38 -05:00
common_hal__eve_BitmapTransformE ( EVEHAL ( self ) , p , v ) ;
2020-02-07 19:44:48 -05:00
return mp_const_none ;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_3 ( bitmaptransforme_obj , _bitmaptransforme ) ;
2020-02-03 19:46:14 -05:00
2020-08-03 00:35:43 -04:00
//| def BitmapTransformF(self, v: int) -> None:
//| """Set the :math:`f` component of the bitmap transform matrix
2020-02-07 19:44:48 -05:00
//|
2020-08-03 00:35:43 -04:00
//| :param int v: The :math:`f` component of the bitmap transform matrix, in signed 15.8 bit fixed-point form. Range 0-16777215. The initial value is 0
2020-02-07 19:44:48 -05:00
//|
2023-02-01 03:08:41 -05:00
//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.
//| """
2020-08-03 00:35:43 -04:00
//| ...
2020-02-07 19:44:48 -05:00
2020-02-10 22:34:38 -05:00
STATIC mp_obj_t _bitmaptransformf ( mp_obj_t self , mp_obj_t a0 ) {
2021-03-15 09:57:36 -04:00
uint32_t v = mp_obj_get_int_truncated ( a0 ) ;
2020-02-10 22:34:38 -05:00
common_hal__eve_BitmapTransformF ( EVEHAL ( self ) , v ) ;
2020-02-07 19:44:48 -05:00
return mp_const_none ;
}
2020-02-10 22:34:38 -05:00
STATIC MP_DEFINE_CONST_FUN_OBJ_2 ( bitmaptransformf_obj , _bitmaptransformf ) ;
2020-02-07 19:44:48 -05:00
2020-08-03 00:35:43 -04:00
//| def BlendFunc(self, src: int, dst: int) -> None:
//| """Set pixel arithmetic
2020-02-07 19:44:48 -05:00
//|
2020-08-03 00:35:43 -04:00
//| :param int src: specifies how the source blending factor is computed. One of ``ZERO``, ``ONE``, ``SRC_ALPHA``, ``DST_ALPHA``, ``ONE_MINUS_SRC_ALPHA`` or ``ONE_MINUS_DST_ALPHA``. Range 0-7. The initial value is SRC_ALPHA(2)
//| :param int dst: specifies how the destination blending factor is computed, one of the same constants as **src**. Range 0-7. The initial value is ONE_MINUS_SRC_ALPHA(4)
2020-02-07 19:44:48 -05:00
//|
2023-02-01 03:08:41 -05:00
//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.
//| """
2020-08-03 00:35:43 -04:00
//| ...
2020-02-07 19:44:48 -05:00
STATIC mp_obj_t _blendfunc ( mp_obj_t self , mp_obj_t a0 , mp_obj_t a1 ) {
2021-03-15 09:57:36 -04:00
uint32_t src = mp_obj_get_int_truncated ( a0 ) ;
uint32_t dst = mp_obj_get_int_truncated ( a1 ) ;
2020-02-07 19:44:48 -05:00
common_hal__eve_BlendFunc ( EVEHAL ( self ) , src , dst ) ;
return mp_const_none ;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_3 ( blendfunc_obj , _blendfunc ) ;
2020-08-03 00:35:43 -04:00
//| def Call(self, dest: int) -> None:
//| """Execute a sequence of commands at another location in the display list
2020-02-07 19:44:48 -05:00
//|
2020-08-03 00:35:43 -04:00
//| :param int dest: display list address. Range 0-65535"""
//| ...
2020-02-07 19:44:48 -05:00
STATIC mp_obj_t _call ( mp_obj_t self , mp_obj_t a0 ) {
2021-03-15 09:57:36 -04:00
uint32_t dest = mp_obj_get_int_truncated ( a0 ) ;
2020-02-07 19:44:48 -05:00
common_hal__eve_Call ( EVEHAL ( self ) , dest ) ;
return mp_const_none ;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2 ( call_obj , _call ) ;
2020-08-03 00:35:43 -04:00
//| def Cell(self, cell: int) -> None:
//| """Set the bitmap cell number for the vertex2f command
2020-02-07 19:44:48 -05:00
//|
2020-08-03 00:35:43 -04:00
//| :param int cell: bitmap cell number. Range 0-127. The initial value is 0
2020-02-07 19:44:48 -05:00
//|
2023-02-01 03:08:41 -05:00
//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.
//| """
2020-08-03 00:35:43 -04:00
//| ...
2020-02-07 19:44:48 -05:00
STATIC mp_obj_t _cell ( mp_obj_t self , mp_obj_t a0 ) {
2021-03-15 09:57:36 -04:00
uint32_t cell = mp_obj_get_int_truncated ( a0 ) ;
2020-02-07 19:44:48 -05:00
common_hal__eve_Cell ( EVEHAL ( self ) , cell ) ;
return mp_const_none ;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2 ( cell_obj , _cell ) ;
2020-08-03 00:35:43 -04:00
//| def ClearColorA(self, alpha: int) -> None:
//| """Set clear value for the alpha channel
2020-02-07 19:44:48 -05:00
//|
2020-08-03 00:35:43 -04:00
//| :param int alpha: alpha value used when the color buffer is cleared. Range 0-255. The initial value is 0
2020-02-07 19:44:48 -05:00
//|
2023-02-01 03:08:41 -05:00
//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.
//| """
2020-08-03 00:35:43 -04:00
//| ...
2020-02-07 19:44:48 -05:00
STATIC mp_obj_t _clearcolora ( mp_obj_t self , mp_obj_t a0 ) {
2021-03-15 09:57:36 -04:00
uint32_t alpha = mp_obj_get_int_truncated ( a0 ) ;
2020-02-07 19:44:48 -05:00
common_hal__eve_ClearColorA ( EVEHAL ( self ) , alpha ) ;
return mp_const_none ;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2 ( clearcolora_obj , _clearcolora ) ;
2020-08-03 00:35:43 -04:00
//| def ClearColorRGB(self, red: int, green: int, blue: int) -> None:
//| """Set clear values for red, green and blue channels
2020-02-07 19:44:48 -05:00
//|
2020-08-03 00:35:43 -04:00
//| :param int red: red value used when the color buffer is cleared. Range 0-255. The initial value is 0
//| :param int green: green value used when the color buffer is cleared. Range 0-255. The initial value is 0
//| :param int blue: blue value used when the color buffer is cleared. Range 0-255. The initial value is 0
2020-02-07 19:44:48 -05:00
//|
2023-02-01 03:08:41 -05:00
//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.
//| """
2020-08-03 00:35:43 -04:00
//| ...
2020-02-07 19:44:48 -05:00
STATIC mp_obj_t _clearcolorrgb ( size_t n_args , const mp_obj_t * args ) {
2021-03-15 09:57:36 -04:00
uint32_t red = mp_obj_get_int_truncated ( args [ 1 ] ) ;
uint32_t green = mp_obj_get_int_truncated ( args [ 2 ] ) ;
uint32_t blue = mp_obj_get_int_truncated ( args [ 3 ] ) ;
2020-02-07 19:44:48 -05:00
common_hal__eve_ClearColorRGB ( EVEHAL ( args [ 0 ] ) , red , green , blue ) ;
return mp_const_none ;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN ( clearcolorrgb_obj , 4 , 4 , _clearcolorrgb ) ;
2020-08-03 00:35:43 -04:00
//| def Clear(self, c: int, s: int, t: int) -> None:
//| """Clear buffers to preset values
2020-02-07 19:44:48 -05:00
//|
2020-08-03 00:35:43 -04:00
//| :param int c: clear color buffer. Range 0-1
//| :param int s: clear stencil buffer. Range 0-1
//| :param int t: clear tag buffer. Range 0-1"""
//| ...
2020-02-07 19:44:48 -05:00
STATIC mp_obj_t _clear ( size_t n_args , const mp_obj_t * args ) {
2021-03-15 09:57:36 -04:00
uint32_t c = ( n_args > 1 ) ? mp_obj_get_int_truncated ( args [ 1 ] ) : 1 ;
uint32_t s = ( n_args > 2 ) ? mp_obj_get_int_truncated ( args [ 2 ] ) : 1 ;
uint32_t t = ( n_args > 3 ) ? mp_obj_get_int_truncated ( args [ 3 ] ) : 1 ;
2020-02-07 19:44:48 -05:00
common_hal__eve_Clear ( EVEHAL ( args [ 0 ] ) , c , s , t ) ;
return mp_const_none ;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN ( clear_obj , 1 , 4 , _clear ) ;
2020-08-03 00:35:43 -04:00
//| def ClearStencil(self, s: int) -> None:
//| """Set clear value for the stencil buffer
2020-02-07 19:44:48 -05:00
//|
2020-08-03 00:35:43 -04:00
//| :param int s: value used when the stencil buffer is cleared. Range 0-255. The initial value is 0
2020-02-07 19:44:48 -05:00
//|
2023-02-01 03:08:41 -05:00
//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.
//| """
2020-08-03 00:35:43 -04:00
//| ...
2020-02-07 19:44:48 -05:00
STATIC mp_obj_t _clearstencil ( mp_obj_t self , mp_obj_t a0 ) {
2021-03-15 09:57:36 -04:00
uint32_t s = mp_obj_get_int_truncated ( a0 ) ;
2020-02-07 19:44:48 -05:00
common_hal__eve_ClearStencil ( EVEHAL ( self ) , s ) ;
return mp_const_none ;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2 ( clearstencil_obj , _clearstencil ) ;
2020-08-03 00:35:43 -04:00
//| def ClearTag(self, s: int) -> None:
//| """Set clear value for the tag buffer
2020-02-07 19:44:48 -05:00
//|
2020-08-03 00:35:43 -04:00
//| :param int s: value used when the tag buffer is cleared. Range 0-255. The initial value is 0
2020-02-07 19:44:48 -05:00
//|
2023-02-01 03:08:41 -05:00
//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.
//| """
2020-02-07 19:44:48 -05:00
STATIC mp_obj_t _cleartag ( mp_obj_t self , mp_obj_t a0 ) {
2021-03-15 09:57:36 -04:00
uint32_t s = mp_obj_get_int_truncated ( a0 ) ;
2020-02-07 19:44:48 -05:00
common_hal__eve_ClearTag ( EVEHAL ( self ) , s ) ;
return mp_const_none ;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2 ( cleartag_obj , _cleartag ) ;
2020-08-03 00:35:43 -04:00
//| def ColorA(self, alpha: int) -> None:
//| """Set the current color alpha
2020-02-07 19:44:48 -05:00
//|
2020-08-03 00:35:43 -04:00
//| :param int alpha: alpha for the current color. Range 0-255. The initial value is 255
2020-02-07 19:44:48 -05:00
//|
2023-02-01 03:08:41 -05:00
//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.
//| """
2020-08-03 00:35:43 -04:00
//| ...
2020-02-07 19:44:48 -05:00
STATIC mp_obj_t _colora ( mp_obj_t self , mp_obj_t a0 ) {
2021-03-15 09:57:36 -04:00
uint32_t alpha = mp_obj_get_int_truncated ( a0 ) ;
2020-02-07 19:44:48 -05:00
common_hal__eve_ColorA ( EVEHAL ( self ) , alpha ) ;
return mp_const_none ;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2 ( colora_obj , _colora ) ;
2020-08-03 00:35:43 -04:00
//| def ColorMask(self, r: int, g: int, b: int, a: int) -> None:
//| """Enable and disable writing of frame buffer color components
2020-02-07 19:44:48 -05:00
//|
2020-08-03 00:35:43 -04:00
//| :param int r: allow updates to the frame buffer red component. Range 0-1. The initial value is 1
//| :param int g: allow updates to the frame buffer green component. Range 0-1. The initial value is 1
//| :param int b: allow updates to the frame buffer blue component. Range 0-1. The initial value is 1
//| :param int a: allow updates to the frame buffer alpha component. Range 0-1. The initial value is 1
2020-02-07 19:44:48 -05:00
//|
2023-02-01 03:08:41 -05:00
//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.
//| """
2020-08-03 00:35:43 -04:00
//| ...
2020-02-07 19:44:48 -05:00
STATIC mp_obj_t _colormask ( size_t n_args , const mp_obj_t * args ) {
2021-03-15 09:57:36 -04:00
uint32_t r = mp_obj_get_int_truncated ( args [ 1 ] ) ;
uint32_t g = mp_obj_get_int_truncated ( args [ 2 ] ) ;
uint32_t b = mp_obj_get_int_truncated ( args [ 3 ] ) ;
uint32_t a = mp_obj_get_int_truncated ( args [ 4 ] ) ;
2020-02-07 19:44:48 -05:00
common_hal__eve_ColorMask ( EVEHAL ( args [ 0 ] ) , r , g , b , a ) ;
return mp_const_none ;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN ( colormask_obj , 5 , 5 , _colormask ) ;
2020-08-03 00:35:43 -04:00
//| def ColorRGB(self, red: int, green: int, blue: int) -> None:
//| """Set the drawing color
2020-02-07 19:44:48 -05:00
//|
2020-08-03 00:35:43 -04:00
//| :param int red: red value for the current color. Range 0-255. The initial value is 255
//| :param int green: green for the current color. Range 0-255. The initial value is 255
//| :param int blue: blue for the current color. Range 0-255. The initial value is 255
2020-02-07 19:44:48 -05:00
//|
2023-02-01 03:08:41 -05:00
//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.
//| """
2020-08-03 00:35:43 -04:00
//| ...
2020-02-07 19:44:48 -05:00
STATIC mp_obj_t _colorrgb ( size_t n_args , const mp_obj_t * args ) {
2021-03-15 09:57:36 -04:00
uint32_t red = mp_obj_get_int_truncated ( args [ 1 ] ) ;
uint32_t green = mp_obj_get_int_truncated ( args [ 2 ] ) ;
uint32_t blue = mp_obj_get_int_truncated ( args [ 3 ] ) ;
2020-02-07 19:44:48 -05:00
common_hal__eve_ColorRGB ( EVEHAL ( args [ 0 ] ) , red , green , blue ) ;
return mp_const_none ;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN ( colorrgb_obj , 4 , 4 , _colorrgb ) ;
2020-08-03 00:35:43 -04:00
//| def Display(self) -> None:
//| """End the display list"""
//| ...
2020-02-07 19:44:48 -05:00
STATIC mp_obj_t _display ( mp_obj_t self ) {
common_hal__eve_Display ( EVEHAL ( self ) ) ;
return mp_const_none ;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1 ( display_obj , _display ) ;
2020-08-03 00:35:43 -04:00
//| def End(self) -> None:
//| """End drawing a graphics primitive
2020-02-07 19:44:48 -05:00
//|
2023-02-01 03:08:41 -05:00
//| :meth:`Vertex2ii` and :meth:`Vertex2f` calls are ignored until the next :meth:`Begin`.
//| """
2020-08-03 00:35:43 -04:00
//| ...
2020-02-07 19:44:48 -05:00
STATIC mp_obj_t _end ( mp_obj_t self ) {
common_hal__eve_End ( EVEHAL ( self ) ) ;
return mp_const_none ;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1 ( end_obj , _end ) ;
2020-08-03 00:35:43 -04:00
//| def Jump(self, dest: int) -> None:
//| """Execute commands at another location in the display list
2020-02-07 19:44:48 -05:00
//|
2020-08-03 00:35:43 -04:00
//| :param int dest: display list address. Range 0-65535"""
//| ...
2020-02-07 19:44:48 -05:00
STATIC mp_obj_t _jump ( mp_obj_t self , mp_obj_t a0 ) {
2021-03-15 09:57:36 -04:00
uint32_t dest = mp_obj_get_int_truncated ( a0 ) ;
2020-02-07 19:44:48 -05:00
common_hal__eve_Jump ( EVEHAL ( self ) , dest ) ;
return mp_const_none ;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2 ( jump_obj , _jump ) ;
2020-08-03 00:35:43 -04:00
//| def Macro(self, m: int) -> None:
//| """Execute a single command from a macro register
2020-02-07 19:44:48 -05:00
//|
2020-08-03 00:35:43 -04:00
//| :param int m: macro register to read. Range 0-1"""
//| ...
2020-02-07 19:44:48 -05:00
STATIC mp_obj_t _macro ( mp_obj_t self , mp_obj_t a0 ) {
2021-03-15 09:57:36 -04:00
uint32_t m = mp_obj_get_int_truncated ( a0 ) ;
2020-02-07 19:44:48 -05:00
common_hal__eve_Macro ( EVEHAL ( self ) , m ) ;
return mp_const_none ;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2 ( macro_obj , _macro ) ;
2020-08-03 00:35:43 -04:00
//| def Nop(self) -> None:
//| """No operation"""
//| ...
2020-02-07 19:44:48 -05:00
STATIC mp_obj_t _nop ( mp_obj_t self ) {
common_hal__eve_Nop ( EVEHAL ( self ) ) ;
return mp_const_none ;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1 ( nop_obj , _nop ) ;
2020-08-03 00:35:43 -04:00
//| def PaletteSource(self, addr: int) -> None:
//| """Set the base address of the palette
2020-02-07 19:44:48 -05:00
//|
2020-08-03 00:35:43 -04:00
//| :param int addr: Address in graphics SRAM, 2-byte aligned. Range 0-4194303. The initial value is 0
2020-02-07 19:44:48 -05:00
//|
2023-02-01 03:08:41 -05:00
//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.
//| """
2020-08-03 00:35:43 -04:00
//| ...
2020-02-07 19:44:48 -05:00
STATIC mp_obj_t _palettesource ( mp_obj_t self , mp_obj_t a0 ) {
2021-03-15 09:57:36 -04:00
uint32_t addr = mp_obj_get_int_truncated ( a0 ) ;
2020-02-07 19:44:48 -05:00
common_hal__eve_PaletteSource ( EVEHAL ( self ) , addr ) ;
return mp_const_none ;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2 ( palettesource_obj , _palettesource ) ;
2020-08-03 00:35:43 -04:00
//| def RestoreContext(self) -> None:
//| """Restore the current graphics context from the context stack"""
//| ...
2020-02-07 19:44:48 -05:00
STATIC mp_obj_t _restorecontext ( mp_obj_t self ) {
common_hal__eve_RestoreContext ( EVEHAL ( self ) ) ;
return mp_const_none ;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1 ( restorecontext_obj , _restorecontext ) ;
2020-08-03 00:35:43 -04:00
//| def Return(self) -> None:
//| """Return from a previous call command"""
//| ...
2020-02-07 19:44:48 -05:00
STATIC mp_obj_t _return ( mp_obj_t self ) {
common_hal__eve_Return ( EVEHAL ( self ) ) ;
return mp_const_none ;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1 ( return_obj , _return ) ;
2020-08-03 00:35:43 -04:00
//| def SaveContext(self) -> None:
//| """Push the current graphics context on the context stack"""
//| ...
2020-02-07 19:44:48 -05:00
STATIC mp_obj_t _savecontext ( mp_obj_t self ) {
common_hal__eve_SaveContext ( EVEHAL ( self ) ) ;
return mp_const_none ;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1 ( savecontext_obj , _savecontext ) ;
2020-08-03 00:35:43 -04:00
//| def ScissorSize(self, width: int, height: int) -> None:
//| """Set the size of the scissor clip rectangle
2020-02-07 19:44:48 -05:00
//|
2020-08-03 00:35:43 -04:00
//| :param int width: The width of the scissor clip rectangle, in pixels. Range 0-4095. The initial value is hsize
//| :param int height: The height of the scissor clip rectangle, in pixels. Range 0-4095. The initial value is 2048
2020-02-07 19:44:48 -05:00
//|
2023-02-01 03:08:41 -05:00
//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.
//| """
2020-08-03 00:35:43 -04:00
//| ...
2020-02-07 19:44:48 -05:00
STATIC mp_obj_t _scissorsize ( mp_obj_t self , mp_obj_t a0 , mp_obj_t a1 ) {
2021-03-15 09:57:36 -04:00
uint32_t width = mp_obj_get_int_truncated ( a0 ) ;
2020-02-07 19:44:48 -05:00
uint32_t height = mp_obj_get_int_truncated ( a1 ) ;
common_hal__eve_ScissorSize ( EVEHAL ( self ) , width , height ) ;
return mp_const_none ;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_3 ( scissorsize_obj , _scissorsize ) ;
2020-08-03 00:35:43 -04:00
//| def ScissorXY(self, x: int, y: int) -> None:
//| """Set the top left corner of the scissor clip rectangle
2020-02-07 19:44:48 -05:00
//|
2020-08-03 00:35:43 -04:00
//| :param int x: The :math:`x` coordinate of the scissor clip rectangle, in pixels. Range 0-2047. The initial value is 0
//| :param int y: The :math:`y` coordinate of the scissor clip rectangle, in pixels. Range 0-2047. The initial value is 0
2020-02-07 19:44:48 -05:00
//|
2023-02-01 03:08:41 -05:00
//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.
//| """
2020-08-03 00:35:43 -04:00
//| ...
2020-02-07 19:44:48 -05:00
STATIC mp_obj_t _scissorxy ( mp_obj_t self , mp_obj_t a0 , mp_obj_t a1 ) {
2021-03-15 09:57:36 -04:00
uint32_t x = mp_obj_get_int_truncated ( a0 ) ;
uint32_t y = mp_obj_get_int_truncated ( a1 ) ;
2020-02-07 19:44:48 -05:00
common_hal__eve_ScissorXY ( EVEHAL ( self ) , x , y ) ;
return mp_const_none ;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_3 ( scissorxy_obj , _scissorxy ) ;
2020-08-03 00:35:43 -04:00
//| def StencilFunc(self, func: int, ref: int, mask: int) -> None:
//| """Set function and reference value for stencil testing
2020-02-07 19:44:48 -05:00
//|
2020-08-03 00:35:43 -04:00
//| :param int func: specifies the test function, one of ``NEVER``, ``LESS``, ``LEQUAL``, ``GREATER``, ``GEQUAL``, ``EQUAL``, ``NOTEQUAL``, or ``ALWAYS``. Range 0-7. The initial value is ALWAYS(7)
//| :param int ref: specifies the reference value for the stencil test. Range 0-255. The initial value is 0
//| :param int mask: specifies a mask that is ANDed with the reference value and the stored stencil value. Range 0-255. The initial value is 255
2020-02-07 19:44:48 -05:00
//|
2023-02-01 03:08:41 -05:00
//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.
//| """
2020-08-03 00:35:43 -04:00
//| ...
2020-02-07 19:44:48 -05:00
STATIC mp_obj_t _stencilfunc ( size_t n_args , const mp_obj_t * args ) {
2021-03-15 09:57:36 -04:00
uint32_t func = mp_obj_get_int_truncated ( args [ 1 ] ) ;
uint32_t ref = mp_obj_get_int_truncated ( args [ 2 ] ) ;
uint32_t mask = mp_obj_get_int_truncated ( args [ 3 ] ) ;
2020-02-07 19:44:48 -05:00
common_hal__eve_StencilFunc ( EVEHAL ( args [ 0 ] ) , func , ref , mask ) ;
return mp_const_none ;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN ( stencilfunc_obj , 4 , 4 , _stencilfunc ) ;
2020-08-03 00:35:43 -04:00
//| def StencilMask(self, mask: int) -> None:
//| """Control the writing of individual bits in the stencil planes
2020-02-07 19:44:48 -05:00
//|
2020-08-03 00:35:43 -04:00
//| :param int mask: the mask used to enable writing stencil bits. Range 0-255. The initial value is 255
2020-02-07 19:44:48 -05:00
//|
2023-02-01 03:08:41 -05:00
//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.
//| """
2020-08-03 00:35:43 -04:00
//| ...
2020-02-07 19:44:48 -05:00
STATIC mp_obj_t _stencilmask ( mp_obj_t self , mp_obj_t a0 ) {
2021-03-15 09:57:36 -04:00
uint32_t mask = mp_obj_get_int_truncated ( a0 ) ;
2020-02-07 19:44:48 -05:00
common_hal__eve_StencilMask ( EVEHAL ( self ) , mask ) ;
return mp_const_none ;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2 ( stencilmask_obj , _stencilmask ) ;
2020-08-03 00:35:43 -04:00
//| def StencilOp(self, sfail: int, spass: int) -> None:
//| """Set stencil test actions
2020-02-07 19:44:48 -05:00
//|
2020-08-03 00:35:43 -04:00
//| :param int sfail: specifies the action to take when the stencil test fails, one of ``KEEP``, ``ZERO``, ``REPLACE``, ``INCR``, ``INCR_WRAP``, ``DECR``, ``DECR_WRAP``, and ``INVERT``. Range 0-7. The initial value is KEEP(1)
//| :param int spass: specifies the action to take when the stencil test passes, one of the same constants as **sfail**. Range 0-7. The initial value is KEEP(1)
2020-02-07 19:44:48 -05:00
//|
2023-02-01 03:08:41 -05:00
//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.
//| """
2020-08-03 00:35:43 -04:00
//| ...
2020-02-07 19:44:48 -05:00
STATIC mp_obj_t _stencilop ( mp_obj_t self , mp_obj_t a0 , mp_obj_t a1 ) {
2021-03-15 09:57:36 -04:00
uint32_t sfail = mp_obj_get_int_truncated ( a0 ) ;
uint32_t spass = mp_obj_get_int_truncated ( a1 ) ;
2020-02-07 19:44:48 -05:00
common_hal__eve_StencilOp ( EVEHAL ( self ) , sfail , spass ) ;
return mp_const_none ;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_3 ( stencilop_obj , _stencilop ) ;
2020-08-03 00:35:43 -04:00
//| def TagMask(self, mask: int) -> None:
//| """Control the writing of the tag buffer
2020-02-07 19:44:48 -05:00
//|
2020-08-03 00:35:43 -04:00
//| :param int mask: allow updates to the tag buffer. Range 0-1. The initial value is 1
2020-02-07 19:44:48 -05:00
//|
2023-02-01 03:08:41 -05:00
//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.
//| """
2020-08-03 00:35:43 -04:00
//| ...
2020-02-07 19:44:48 -05:00
STATIC mp_obj_t _tagmask ( mp_obj_t self , mp_obj_t a0 ) {
2021-03-15 09:57:36 -04:00
uint32_t mask = mp_obj_get_int_truncated ( a0 ) ;
2020-02-07 19:44:48 -05:00
common_hal__eve_TagMask ( EVEHAL ( self ) , mask ) ;
return mp_const_none ;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2 ( tagmask_obj , _tagmask ) ;
2020-08-03 00:35:43 -04:00
//| def Tag(self, s: int) -> None:
//| """Set the current tag value
2020-02-07 19:44:48 -05:00
//|
2020-08-03 00:35:43 -04:00
//| :param int s: tag value. Range 0-255. The initial value is 255
2020-02-07 19:44:48 -05:00
//|
2023-02-01 03:08:41 -05:00
//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.
//| """
2020-08-03 00:35:43 -04:00
//| ...
2020-02-07 19:44:48 -05:00
STATIC mp_obj_t _tag ( mp_obj_t self , mp_obj_t a0 ) {
2021-03-15 09:57:36 -04:00
uint32_t s = mp_obj_get_int_truncated ( a0 ) ;
2020-02-07 19:44:48 -05:00
common_hal__eve_Tag ( EVEHAL ( self ) , s ) ;
return mp_const_none ;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2 ( tag_obj , _tag ) ;
STATIC mp_obj_t _vertexformat ( mp_obj_t self , mp_obj_t a0 ) {
2021-03-15 09:57:36 -04:00
uint32_t frac = mp_obj_get_int_truncated ( a0 ) ;
2020-02-07 19:44:48 -05:00
common_hal__eve_VertexFormat ( EVEHAL ( self ) , frac ) ;
return mp_const_none ;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2 ( vertexformat_obj , _vertexformat ) ;
2020-08-03 00:35:43 -04:00
//| def Vertex2ii(self, x: int, y: int, handle: int, cell: int) -> None:
//| """:param int x: x-coordinate in pixels. Range 0-511
//| :param int y: y-coordinate in pixels. Range 0-511
//| :param int handle: bitmap handle. Range 0-31
//| :param int cell: cell number. Range 0-127
2020-02-07 19:44:48 -05:00
//|
2020-08-03 00:35:43 -04:00
//| This method is an alternative to :meth:`Vertex2f`."""
//| ...
2020-02-07 19:44:48 -05:00
STATIC mp_obj_t _vertex2ii ( size_t n_args , const mp_obj_t * args ) {
2021-03-15 09:57:36 -04:00
uint32_t x = mp_obj_get_int_truncated ( args [ 1 ] ) ;
uint32_t y = mp_obj_get_int_truncated ( args [ 2 ] ) ;
2020-02-07 19:44:48 -05:00
uint32_t handle = ( n_args > 3 ) ? mp_obj_get_int_truncated ( args [ 3 ] ) : 0 ;
2021-03-15 09:57:36 -04:00
uint32_t cell = ( n_args > 4 ) ? mp_obj_get_int_truncated ( args [ 4 ] ) : 0 ;
2020-02-07 19:44:48 -05:00
common_hal__eve_Vertex2ii ( EVEHAL ( args [ 0 ] ) , x , y , handle , cell ) ;
return mp_const_none ;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN ( vertex2ii_obj , 3 , 5 , _vertex2ii ) ;
2020-02-13 10:28:21 -05:00
# define ROM_DECLS \
{ MP_ROM_QSTR ( MP_QSTR_AlphaFunc ) , MP_ROM_PTR ( & alphafunc_obj ) } , \
{ MP_ROM_QSTR ( MP_QSTR_Begin ) , MP_ROM_PTR ( & begin_obj ) } , \
{ MP_ROM_QSTR ( MP_QSTR_BitmapExtFormat ) , MP_ROM_PTR ( & bitmapextformat_obj ) } , \
{ MP_ROM_QSTR ( MP_QSTR_BitmapHandle ) , MP_ROM_PTR ( & bitmaphandle_obj ) } , \
{ MP_ROM_QSTR ( MP_QSTR_BitmapLayoutH ) , MP_ROM_PTR ( & bitmaplayouth_obj ) } , \
{ MP_ROM_QSTR ( MP_QSTR_BitmapLayout ) , MP_ROM_PTR ( & bitmaplayout_obj ) } , \
{ MP_ROM_QSTR ( MP_QSTR_BitmapSizeH ) , MP_ROM_PTR ( & bitmapsizeh_obj ) } , \
{ MP_ROM_QSTR ( MP_QSTR_BitmapSize ) , MP_ROM_PTR ( & bitmapsize_obj ) } , \
{ MP_ROM_QSTR ( MP_QSTR_BitmapSource ) , MP_ROM_PTR ( & bitmapsource_obj ) } , \
{ MP_ROM_QSTR ( MP_QSTR_BitmapSwizzle ) , MP_ROM_PTR ( & bitmapswizzle_obj ) } , \
{ MP_ROM_QSTR ( MP_QSTR_BitmapTransformA ) , MP_ROM_PTR ( & bitmaptransforma_obj ) } , \
{ MP_ROM_QSTR ( MP_QSTR_BitmapTransformB ) , MP_ROM_PTR ( & bitmaptransformb_obj ) } , \
{ MP_ROM_QSTR ( MP_QSTR_BitmapTransformC ) , MP_ROM_PTR ( & bitmaptransformc_obj ) } , \
{ MP_ROM_QSTR ( MP_QSTR_BitmapTransformD ) , MP_ROM_PTR ( & bitmaptransformd_obj ) } , \
{ MP_ROM_QSTR ( MP_QSTR_BitmapTransformE ) , MP_ROM_PTR ( & bitmaptransforme_obj ) } , \
{ MP_ROM_QSTR ( MP_QSTR_BitmapTransformF ) , MP_ROM_PTR ( & bitmaptransformf_obj ) } , \
{ MP_ROM_QSTR ( MP_QSTR_BlendFunc ) , MP_ROM_PTR ( & blendfunc_obj ) } , \
{ MP_ROM_QSTR ( MP_QSTR_Call ) , MP_ROM_PTR ( & call_obj ) } , \
{ MP_ROM_QSTR ( MP_QSTR_Cell ) , MP_ROM_PTR ( & cell_obj ) } , \
{ MP_ROM_QSTR ( MP_QSTR_ClearColorA ) , MP_ROM_PTR ( & clearcolora_obj ) } , \
{ MP_ROM_QSTR ( MP_QSTR_ClearColorRGB ) , MP_ROM_PTR ( & clearcolorrgb_obj ) } , \
{ MP_ROM_QSTR ( MP_QSTR_Clear ) , MP_ROM_PTR ( & clear_obj ) } , \
{ MP_ROM_QSTR ( MP_QSTR_ClearStencil ) , MP_ROM_PTR ( & clearstencil_obj ) } , \
{ MP_ROM_QSTR ( MP_QSTR_ClearTag ) , MP_ROM_PTR ( & cleartag_obj ) } , \
{ MP_ROM_QSTR ( MP_QSTR_ColorA ) , MP_ROM_PTR ( & colora_obj ) } , \
{ MP_ROM_QSTR ( MP_QSTR_ColorMask ) , MP_ROM_PTR ( & colormask_obj ) } , \
{ MP_ROM_QSTR ( MP_QSTR_ColorRGB ) , MP_ROM_PTR ( & colorrgb_obj ) } , \
{ MP_ROM_QSTR ( MP_QSTR_Display ) , MP_ROM_PTR ( & display_obj ) } , \
{ MP_ROM_QSTR ( MP_QSTR_End ) , MP_ROM_PTR ( & end_obj ) } , \
{ MP_ROM_QSTR ( MP_QSTR_Jump ) , MP_ROM_PTR ( & jump_obj ) } , \
{ MP_ROM_QSTR ( MP_QSTR_LineWidth ) , MP_ROM_PTR ( & linewidth_obj ) } , \
{ MP_ROM_QSTR ( MP_QSTR_Macro ) , MP_ROM_PTR ( & macro_obj ) } , \
{ MP_ROM_QSTR ( MP_QSTR_Nop ) , MP_ROM_PTR ( & nop_obj ) } , \
{ MP_ROM_QSTR ( MP_QSTR_PaletteSource ) , MP_ROM_PTR ( & palettesource_obj ) } , \
{ MP_ROM_QSTR ( MP_QSTR_PointSize ) , MP_ROM_PTR ( & pointsize_obj ) } , \
{ MP_ROM_QSTR ( MP_QSTR_RestoreContext ) , MP_ROM_PTR ( & restorecontext_obj ) } , \
{ MP_ROM_QSTR ( MP_QSTR_Return ) , MP_ROM_PTR ( & return_obj ) } , \
{ MP_ROM_QSTR ( MP_QSTR_SaveContext ) , MP_ROM_PTR ( & savecontext_obj ) } , \
{ MP_ROM_QSTR ( MP_QSTR_ScissorSize ) , MP_ROM_PTR ( & scissorsize_obj ) } , \
{ MP_ROM_QSTR ( MP_QSTR_ScissorXY ) , MP_ROM_PTR ( & scissorxy_obj ) } , \
{ MP_ROM_QSTR ( MP_QSTR_StencilFunc ) , MP_ROM_PTR ( & stencilfunc_obj ) } , \
{ MP_ROM_QSTR ( MP_QSTR_StencilMask ) , MP_ROM_PTR ( & stencilmask_obj ) } , \
{ MP_ROM_QSTR ( MP_QSTR_StencilOp ) , MP_ROM_PTR ( & stencilop_obj ) } , \
{ MP_ROM_QSTR ( MP_QSTR_TagMask ) , MP_ROM_PTR ( & tagmask_obj ) } , \
{ MP_ROM_QSTR ( MP_QSTR_Tag ) , MP_ROM_PTR ( & tag_obj ) } , \
{ MP_ROM_QSTR ( MP_QSTR_VertexTranslateX ) , MP_ROM_PTR ( & vertextranslatex_obj ) } , \
{ MP_ROM_QSTR ( MP_QSTR_VertexTranslateY ) , MP_ROM_PTR ( & vertextranslatey_obj ) } , \
{ MP_ROM_QSTR ( MP_QSTR_VertexFormat ) , MP_ROM_PTR ( & vertexformat_obj ) } , \
{ MP_ROM_QSTR ( MP_QSTR_Vertex2ii ) , MP_ROM_PTR ( & vertex2ii_obj ) }
2020-02-07 19:44:48 -05:00
2021-03-15 09:57:36 -04:00
// }
2020-02-07 19:44:48 -05:00
// Hand-written functions {
2020-08-03 00:35:43 -04:00
//| def Vertex2f(self, b: float) -> None:
//| """Draw a point.
2020-02-07 19:44:48 -05:00
//|
2020-08-03 00:35:43 -04:00
//| :param float x: pixel x-coordinate
//| :param float y: pixel y-coordinate"""
//| ...
2020-02-06 11:49:07 -05:00
STATIC mp_obj_t _vertex2f ( mp_obj_t self , mp_obj_t a0 , mp_obj_t a1 ) {
2020-02-07 13:30:49 -05:00
mp_float_t x = mp_obj_get_float ( a0 ) ;
mp_float_t y = mp_obj_get_float ( a1 ) ;
common_hal__eve_Vertex2f ( EVEHAL ( self ) , x , y ) ;
2020-02-03 19:46:14 -05:00
return mp_const_none ;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_3 ( vertex2f_obj , _vertex2f ) ;
2021-01-22 18:52:46 -05:00
//| def LineWidth(self, width: float) -> None:
//| """Set the width of rasterized lines
//|
//| :param float width: line width in pixels. Range 0-511. The initial value is 1
//|
2023-02-01 03:08:41 -05:00
//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.
//| """
2021-01-22 18:52:46 -05:00
//| ...
STATIC mp_obj_t _linewidth ( mp_obj_t self , mp_obj_t a0 ) {
2021-03-15 09:57:36 -04:00
mp_float_t width = mp_obj_get_float ( a0 ) ;
2021-01-22 18:52:46 -05:00
common_hal__eve_LineWidth ( EVEHAL ( self ) , width ) ;
return mp_const_none ;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2 ( linewidth_obj , _linewidth ) ;
//| def PointSize(self, size: float) -> None:
//| """Set the diameter of rasterized points
//|
//| :param float size: point diameter in pixels. Range 0-1023. The initial value is 1
//|
2023-02-01 03:08:41 -05:00
//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.
//| """
2021-01-22 18:52:46 -05:00
//| ...
STATIC mp_obj_t _pointsize ( mp_obj_t self , mp_obj_t a0 ) {
2021-03-15 09:57:36 -04:00
mp_float_t size = mp_obj_get_float ( a0 ) ;
2021-01-22 18:52:46 -05:00
common_hal__eve_PointSize ( EVEHAL ( self ) , size ) ;
return mp_const_none ;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2 ( pointsize_obj , _pointsize ) ;
//| def VertexTranslateX(self, x: float) -> None:
//| """Set the vertex transformation's x translation component
//|
//| :param float x: signed x-coordinate in pixels. Range ±4095. The initial value is 0
//|
2023-02-01 03:08:41 -05:00
//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.
//| """
2021-01-22 18:52:46 -05:00
//| ...
STATIC mp_obj_t _vertextranslatex ( mp_obj_t self , mp_obj_t a0 ) {
2021-03-15 09:57:36 -04:00
mp_float_t x = mp_obj_get_float ( a0 ) ;
2021-01-22 18:52:46 -05:00
common_hal__eve_VertexTranslateX ( EVEHAL ( self ) , x ) ;
return mp_const_none ;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2 ( vertextranslatex_obj , _vertextranslatex ) ;
//| def VertexTranslateY(self, y: float) -> None:
//| """Set the vertex transformation's y translation component
//|
//| :param float y: signed y-coordinate in pixels. Range ±4095. The initial value is 0
//|
2023-02-01 03:08:41 -05:00
//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.
//| """
2021-01-22 18:52:46 -05:00
//| ...
STATIC mp_obj_t _vertextranslatey ( mp_obj_t self , mp_obj_t a0 ) {
2021-03-15 09:57:36 -04:00
mp_float_t y = mp_obj_get_float ( a0 ) ;
2021-01-22 18:52:46 -05:00
common_hal__eve_VertexTranslateY ( EVEHAL ( self ) , y ) ;
return mp_const_none ;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2 ( vertextranslatey_obj , _vertextranslatey ) ;
//| def VertexFormat(self, frac: int) -> None:
//| """Set the precision of vertex2f coordinates
//|
//| :param int frac: Number of fractional bits in X,Y coordinates, 0-4. Range 0-7. The initial value is 4
//|
2023-02-01 03:08:41 -05:00
//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.
//| """
2021-01-22 18:52:46 -05:00
//| ...
2021-03-15 09:57:36 -04:00
// }
2021-01-22 18:52:46 -05:00
2020-02-07 19:44:48 -05:00
// Append an object x to the FIFO
# define ADD_X(self, x) \
common_hal__eve_add ( EVEHAL ( self ) , sizeof ( x ) , & ( x ) ) ;
2020-08-03 00:35:43 -04:00
//| def cmd0(self, n: int) -> None:
//| """Append the command word n to the FIFO
2020-02-07 19:44:48 -05:00
//|
2020-08-03 00:35:43 -04:00
//| :param int n: The command code
2020-02-07 19:44:48 -05:00
//|
2020-08-03 00:35:43 -04:00
//| This method is used by the ``eve`` module to efficiently add
//| commands to the FIFO."""
//| ...
2020-02-07 19:44:48 -05:00
STATIC mp_obj_t _cmd0 ( mp_obj_t self , mp_obj_t n ) {
uint32_t code = 0xffffff00 | mp_obj_get_int_truncated ( n ) ;
ADD_X ( self , code ) ;
return mp_const_none ;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2 ( cmd0_obj , _cmd0 ) ;
2020-08-03 00:35:43 -04:00
//| def cmd(self, n: int, fmt: str, args: Tuple[str, ...]) -> None:
//| """Append a command packet to the FIFO.
2020-02-07 19:44:48 -05:00
//|
2020-08-03 00:35:43 -04:00
//| :param int n: The command code
//| :param str fmt: The command format `struct` layout
//| :param args: The command's arguments
//| :type args: tuple(str, ...)
2020-02-07 19:44:48 -05:00
//|
2020-08-03 00:35:43 -04:00
//| Supported format codes: h, H, i, I.
2020-02-07 19:44:48 -05:00
//|
2020-08-03 00:35:43 -04:00
//| This method is used by the ``eve`` module to efficiently add
//| commands to the FIFO."""
//| ...
2022-09-29 20:22:32 -04:00
//|
2020-02-03 19:46:14 -05:00
STATIC mp_obj_t _cmd ( size_t n_args , const mp_obj_t * args ) {
mp_obj_t self = args [ 0 ] ;
mp_obj_t num = args [ 1 ] ;
mp_buffer_info_t fmt ;
mp_get_buffer_raise ( args [ 2 ] , & fmt , MP_BUFFER_READ ) ;
size_t len ;
mp_obj_t * items ;
mp_obj_tuple_get ( args [ 3 ] , & len , & items ) ;
// Count how many 32-bit words required
size_t n = 0 ;
for ( size_t i = 0 ; i < fmt . len ; n + + ) {
2021-03-15 09:57:36 -04:00
switch ( ( ( char * ) fmt . buf ) [ i ] ) {
2020-02-03 19:46:14 -05:00
case ' I ' :
case ' i ' :
i + = 1 ;
break ;
case ' H ' :
case ' h ' :
i + = 2 ;
break ;
default :
break ;
}
}
2020-02-07 13:30:49 -05:00
uint32_t buf [ 16 ] ;
uint32_t * p = buf ;
2020-02-03 19:46:14 -05:00
* p + + = 0xffffff00 | mp_obj_get_int_truncated ( num ) ;
mp_obj_t * a = items ;
uint32_t lo ;
2021-03-15 09:57:36 -04:00
for ( size_t i = 0 ; i < fmt . len ; ) {
switch ( ( ( char * ) fmt . buf ) [ i ] ) {
2020-02-03 19:46:14 -05:00
case ' I ' :
case ' i ' :
* p + + = mp_obj_get_int_truncated ( * a + + ) ;
i + = 1 ;
break ;
case ' H ' :
case ' h ' :
lo = mp_obj_get_int_truncated ( * a + + ) & 0xffff ;
* p + + = lo | ( mp_obj_get_int_truncated ( * a + + ) < < 16 ) ;
i + = 2 ;
break ;
default :
break ;
}
}
2020-02-07 13:30:49 -05:00
common_hal__eve_add ( EVEHAL ( self ) , sizeof ( uint32_t ) * ( 1 + n ) , buf ) ;
2020-02-03 19:46:14 -05:00
return mp_const_none ;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN ( cmd_obj , 4 , 4 , _cmd ) ;
2020-02-05 21:17:58 -05:00
STATIC const mp_rom_map_elem_t _EVE_locals_dict_table [ ] = {
2020-02-03 19:46:14 -05:00
{ MP_ROM_QSTR ( MP_QSTR_register ) , MP_ROM_PTR ( & register_obj ) } ,
{ MP_ROM_QSTR ( MP_QSTR_cc ) , MP_ROM_PTR ( & cc_obj ) } ,
{ MP_ROM_QSTR ( MP_QSTR_flush ) , MP_ROM_PTR ( & flush_obj ) } ,
{ MP_ROM_QSTR ( MP_QSTR_Vertex2f ) , MP_ROM_PTR ( & vertex2f_obj ) } ,
{ MP_ROM_QSTR ( MP_QSTR_cmd ) , MP_ROM_PTR ( & cmd_obj ) } ,
{ MP_ROM_QSTR ( MP_QSTR_cmd0 ) , MP_ROM_PTR ( & cmd0_obj ) } ,
ROM_DECLS
} ;
2020-02-05 21:17:58 -05:00
STATIC MP_DEFINE_CONST_DICT ( _EVE_locals_dict , _EVE_locals_dict_table ) ;
2020-02-03 19:46:14 -05:00
Merge tag 'v1.17' into merge-1.17
F-strings, new machine.I2S class, ESP32-C3 support and LEGO_HUB_NO6 board
This release of MicroPython adds support for f-strings (PEP-498), with a
few limitations compared to normal Python. F-strings are essentially
syntactic sugar for "".format() and make formatting strings a lot more
convenient. Other improvements to the core runtime include pretty printing
OSError when it has two arguments (an errno code and a string), scheduling
of KeyboardInterrupt on the main thread, and support for a single argument
to the optimised form of StopIteration.
In the machine module a new I2S class has been added, with support for
esp32 and stm32 ports. This provides a consistent API for transmit and
receive of audio data in blocking, non-blocking and asyncio-based
operation. Also, the json module has support for the "separators" argument
in the dump and dumps functions, and framebuf now includes a way to blit
between frame buffers of different formats using a palette. A new,
portable machine.bitstream function is also added which can output a stream
of bits with configurable timing, and is used as the basis for driving
WS2812 LEDs in a common way across ports.
There has been some restructuring of the repository directory layout, with
all third-party code now in the lib/ directory. And a new top-level
directory shared/ has been added with first-party code that was previously
in lib/ moved there.
The docs have seen further improvement with enhancements and additions to
the rp2 parts, as well as a new quick reference for the zephyr port.
The terms master/slave have been replaced with controller/peripheral,
mainly relating to I2C and SPI usage. And u-module references have been
replaced with just the module name without the u-prefix to help clear up
the intended usage of modules in MicroPython.
For the esp8266 and esp32 ports, hidden networks are now included in WLAN
scan results. On the esp32 the RMT class is enhanced with idle_level and
write_pulses modes. There is initial support for ESP32-C3 chips with
GENERIC_C3 and GENERIC_C3_USB boards.
The javascript port has had its Makefile and garbage collector
implementation reworked so it compiles and runs with latest the Emscripten
using asyncify.
The mimxrt port sees the addition of hardware I2C and SPI support, as well
as some additional methods to the machine module. There is also support
for Hyperflash chips.
The nrf port now has full VFS storage support, enables source-line on
traceback, and has .mpy features consistent with other ports.
For the rp2 port there is now more configurability for boards, and more
boards added.
The stm32 port has a new LEGO_HUB_NO6 board definition with detailed
information how to get this LEGO Hub running stock MicroPython. There is
also now support to change the CPU frequency on STM32WB MCUs. And USBD_xxx
descriptor options have been renamed to MICROPY_HW_USB_xxx.
Thanks to everyone who contributed to this release: Amir Gonnen, Andrew
Scheller, Bryan Tong Minh, Chris Wilson, Damien George, Daniel Mizyrycki,
David Lechner, David P, Fernando, finefoot, Frank Pilhofer, Glenn Ruben
Bakke, iabdalkader, Jeff Epler, Jim Mussared, Jonathan Hogg, Josh Klar,
Josh Lloyd, Julia Hathaway, Krzysztof Adamski, Matúš Olekšák, Michael
Weiss, Michel Bouwmans, Mike Causer, Mike Teachman, Ned Konz, NitiKaur,
oclyke, Patrick Van Oosterwijck, Peter Hinch, Peter Züger, Philipp
Ebensberger, robert-hh, Roberto Colistete Jr, Sashkoiv, Seon Rozenblum,
Tobias Thyrrestrup, Tom McDermott, Will Sowerbutts, Yonatan Goldschmidt.
What follows is a detailed list of changes, generated from the git commit
history, and organised into sections.
Main components
===============
all:
- fix signed shifts and NULL access errors from -fsanitize=undefined
- update to point to files in new shared/ directory
py core:
- mpstate: make exceptions thread-local
- mpstate: schedule KeyboardInterrupt on main thread
- mperrno: add MP_ECANCELED error code
- makeqstrdefs.py: don't include .h files explicitly in preprocessing
- mark unused arguments from bytecode decoding macros
- objexcept: pretty print OSError also when it has 2 arguments
- makeversionhdr: add --tags arg to git describe
- vm: simplify handling of MP_OBJ_STOP_ITERATION in yield-from opcode
- objexcept: make mp_obj_exception_get_value support subclassed excs
- support single argument to optimised MP_OBJ_STOP_ITERATION
- introduce and use mp_raise_type_arg helper
- modsys: optimise sys.exit for code size by using exception helpers
- objexcept: make mp_obj_new_exception_arg1 inline
- obj: fix formatting of comment for mp_obj_is_integer
- emitnative: reuse need_reg_all func in need_stack_settled
- emitnative: ensure stack settling is safe mid-branch
- runtime: fix bool unary op for subclasses of native types
- builtinimport: fix condition for including do_execute_raw_code()
- mkrules: automatically build mpy-cross if it doesn't exist
- implement partial PEP-498 (f-string) support
- lexer: clear fstring_args vstr on lexer free
- mkrules.mk: do submodule sync in "make submodules"
extmod:
- btstack: add missing call to mp_bluetooth_hci_uart_deinit
- btstack: check that BLE is active before performing operations
- uasyncio: get addr and bind server socket before creating task
- axtls-include: add axtls_os_port.h to customise axTLS
- update for move of crypto-algorithms, re1.5, uzlib to lib
- moduselect: conditionally compile select()
- nimble: fix leak in l2cap_send if send-while-stalled
- btstack/btstack.mk: use -Wno-implicit-fallthrough, not =0
- utime: always invoke mp_hal_delay_ms when >= to 0ms
- modbluetooth: clamp MTU values to 32->UINT16_MAX
- nimble: allow modbluetooth binding to hook "sent HCI packet"
- nimble: add "memory stalling" mechanism for l2cap_send
- uasyncio: in open_connection use address info in socket creation
- modujson: add support for dump/dumps separators keyword-argument
- modlwip: fix close and clean up of UDP and raw sockets
- modbluetooth: add send_update arg to gatts_write
- add machine.bitstream
- modframebuf: enable blit between different formats via a palette
lib:
- tinyusb: update to version 0.10.1
- pico-sdk: update to version 1.2.0
- utils/stdout_helpers: make mp_hal_stdout_tx_strn_cooked efficient
- axtls: switch to repo at micropython/axtls
- axtls: update to latest axtls 2.1.5 wih additional commits
- re1.5: move re1.5 code from extmod to lib
- uzlib: move uzlib code from extmod to lib
- crypto-algorithms: move crypto-algorithms code from extmod to lib
- update README's based on contents of these dirs
drivers:
- neopixel: add common machine.bitstream-based neopixel module
- neopixel: optimize fill() for speed
- neopixel: reduce code size of driver
- cyw43: fix cyw43_deinit so it can be called many times in a row
- cyw43: make wifi join fail if interface is not active
mpy-cross:
- disable stack check when building with Emscripten
Support components
==================
docs:
- library: document new esp32.RMT features and fix wait_done
- library: warn that ustruct doesn't handle spaces in format strings
- esp8266/tutorial: change flash mode from dio to dout
- replace master/slave with controller/peripheral in I2C and SPI
- rp2: enhance quickref and change image to Pico pinout
- rp2: update general section to give a brief technical overview
- library/utime.rst: clarify behaviour and precision of sleep ms/us
- library/uasyncio.rst: document stream readexactly() method
- library/machine.I2S.rst: fix use of sd pin in examples
- zephyr: add quick reference for the Zephyr port
- library/zephyr: add libraries specific to the Zephyr port
- templates: add unix and zephyr quickref links to top-index
- rename ufoo.rst to foo.rst
- replace ufoo with foo in all docs
- library/index.rst: clarify module naming and purpose
- library/builtins.rst: add module title
- library/network.rst: simplify socket import
- add docs for machine.bitstream and neopixel module
- library: fix usage of :term: for frozen module reference
- esp8266: use monospace for software tools
- reference: mention that slicing a memoryview causes allocation
examples: no changes specific to this component/port
tests:
- extmod: make uasyncio_heaplock test more deterministic
- cpydiff/modules_struct_whitespace_in_format: run black
- extmod/ujson: add tests for dump/dumps separators argument
- run-multitests.py: add broadcast and wait facility
- multi_bluetooth/ble_subscribe.py: add test for subscription
- extmod/vfs_fat_finaliser.py: ensure alloc at never-used GC blocks
- basics: split f-string debug printing to separate file with .exp
- pybnative: make while.py test run on boards without pyb.delay
tools:
- autobuild: add scripts to build release firmware
- remove obsolete build-stm-latest.sh script
- ci.sh: run apt-get update in ci_powerpc_setup
- makemanifest.py: allow passing flags to mpy-tool.py
- autobuild: add mimxrt port to build scripts for nightly builds
- pyboard.py: add cmd-line option to make soft reset configurable
- mpremote: swap order of PID and VID in connect-list output
- ci.sh: build unix dev variant as part of macOS CI
- ci.sh: build GENERIC_C3 board as part of esp32 CI
- autobuild: use separate IDF version to build newer esp32 SoCs
- autobuild: add FeatherS2 and TinyS2 to esp32 auto builds
- mpremote: add seek whence for mounted files
- mpremote: raise OSError on unsupported RemoteFile.seek
- autobuild: add the MIMXRT1050_EVKB board to the daily builds
- ci.sh: add mpy-cross build to nrf port
- codeformat.py: include ports/nrf/modules/nrf in code formatting
- gen-cpydiff.py: don't rename foo to ufoo in diff output
- autobuild: add auto build for Silicognition wESP32
- mpremote: fix connect-list in case VID/PID are None
- mpremote: add "devs" shortcut for "connect list"
- mpremote: remove support for pyb.USB_VCP in/out specialisation
- autobuild: don't use "-B" for make, it's already a fresh build
- pyboard.py: move --no-exclusive/--soft-reset out of mutex group
- pyboard.py: make --no-follow use same variable as --follow
- pyboard.py: add --exclusive to match --no-exclusive
- pyboard.py: make --no-soft-reset consistent with other args
- uncrustify: force 1 newline at end of file
- mpremote: bump version to 0.0.6
CI:
- workflows: add workflow to build and test javascript port
- workflows: switch from Coveralls to Codecov
- workflows: switch from lcov to gcov
- workflows: add workflow to build and test unix dev variant
The ports
=========
all ports:
- use common mp_hal_stdout_tx_strn_cooked instead of custom one
- update for move of crypto-algorithms, uzlib to lib
- rename USBD_VID/PID config macros to MICROPY_HW_USB_VID/PID
bare-arm port: no changes specific to this component/port
cc3200 port: no changes specific to this component/port
esp8266 port:
- add __len__ to NeoPixel driver to support iterating
- Makefile: add more libm files to build
- include hidden networks in WLAN.scan results
- replace esp.neopixel with machine.bitstream
- remove dead code for end_ticks in machine_bitstream
esp32 port:
- boards/sdkconfig.base: disable MEMPROT_FEATURE to alloc from IRAM
- add __len__ to NeoPixel driver to support iterating
- main: allow MICROPY_DIR to be overridden
- esp32_rmt: fix RMT looping in newer IDF versions
- esp32_rmt: enhance RMT with idle_level and write_pulses modes
- add new machine.I2S class for I2S protocol support
- machine_spi: calculate actual attained baudrate
- machine_hw_spi: use a 2 item SPI queue for long transfers
- machine_dac: add MICROPY_PY_MACHINE_DAC option, enable by default
- machine_i2s: add MICROPY_PY_MACHINE_I2S option, enable by default
- fix use of mp_int_t, size_t and uintptr_t
- add initial support for ESP32C3 SoCs
- boards/GENERIC_C3: add generic C3-based board
- modmachine: release the GIL in machine.idle()
- mphalport: always yield at least once in delay_ms
- machine_uart: add flow kw-arg to enable hardware flow control
- boards: add Silicognition wESP32 board configuration
- mpconfigport.h: enable reverse and inplace special methods
- include hidden networks in WLAN.scan results
- makeimg.py: get bootloader and partition offset from sdkconfig
- enable MICROPY_PY_FSTRINGS by default
- machine_hw_spi: release GIL during transfers
- machine_pin: make check for non-output pins respect chip variant
- replace esp.neopixel with machine.bitstream
- remove dead code for end_ticks in machine_bitstream
- boards: add GENERIC_C3_USB board with USB serial/JTAG support
javascript port:
- rework Makefile and GC so it works with latest Emscripten
- Makefile: suppress compiler errors from array bounds
- Makefile: change variable to EXPORTED_RUNTIME_METHODS
mimxrt port:
- move calc_weekday helper function to timeutils
- machine_spi: add the SPI class to the machine module
- moduos: seed the PRNG on boot using the TRNG
- boards: set vfs partition start to 1 MBbyte
- main: skip running main.py if boot.py failed
- main: extend the information returned by help()
- mimxrt_flash: remove commented-out code
- modmachine: add a few minor methods to the machine module
- machine_led: use mp_raise_msg_varg helper
- machine_i2c: add hardware-based machine.I2C to machine module
- add support for Hyperflash chips
- boards: add support for the MIMXRT1050_EVKB board
- machine_pin: implement ioctl for Pin
minimal port:
- Makefile: add support for building with user C modules
nrf port:
- modules: replace master/slave with controller/peripheral in SPI
- boards/common.ld: calculate unused flash region
- modules/nrf: add new nrf module with flash block device
- drivers: add support for using flash block device with SoftDevice
- mpconfigport.h: expose nrf module when MICROPY_PY_NRF is set
- README: update README.md to reflect internal file systems
- mpconfigport.h: tune FAT FS configuration
- Makefile: add _fs_size linker script override from make
- modules/uos: allow a board to configure MICROPY_VFS_FAT/LFS1/LFS2
- mpconfigport.h: enable MICROPY_PY_IO_FILEIO when an FS is enabled
- qstrdefsport.h: add entries for in-built FS mount points
- main: add auto mount and auto format hook for internal flash FS
- boards: enable needed features for FAT/LFS1/LFS2
- facilitate use of freeze manifest
- boards: set FROZEN_MANIFEST blank when SD present on nrf51 targets
- modules/scripts: add file system formatting script
- Makefile: set default manifest file for all targets
- mphalport: add dummy function for mp_hal_time_ns()
- boards: enable MICROPY_VFS_LFS2 for all target boards
- modules/uos: add ilistdir to uos module
- modules/nrf: add function to enable/disable DCDC
- enable source line on tracebacks
- set .mpy features consistent with documentation and other ports
pic16bit port: no changes specific to this component/port
powerpc port: no changes specific to this component/port
qemu-arm port: no changes specific to this component/port
rp2 port:
- use 0=Monday datetime convention in RTC
- machine_rtc: in RTC.datetime, compute weekday automatically
- CMakeLists.txt: suppress compiler errors for pico-sdk and tinyusb
- tusb_config.h: set CFG_TUD_CDC_EP_BUFSIZE to 256
- machine_uart: add hardware flow control support
- machine_uart: allow overriding default machine UART pins
- machine_i2c: allow boards to configure I2C pins using new macros
- machine_spi: allow boards to configure SPI pins using new macros
- machine_uart: fix poll ioctl to also check hardware FIFO
- machine_uart: fix read when FIFO has chars but ringbuf doesn't
- tusb_port: allow boards to configure USB VID and PID
- boards/ADAFRUIT_FEATHER_RP2040: configure custom VID/PID
- boards/ADAFRUIT_FEATHER_RP2040: configure I2C/SPI default pins
- boards/SPARKFUN_PROMICRO: configure UART/I2C/SPI default pins
- boards/SPARKFUN_THINGPLUS: configure I2C/SPI default pins
- boards: add Adafruit ItsyBitsy RP2040
- boards: add Adafruit QT Py RP2040
- boards: add Pimoroni Pico LiPo 4MB
- boards: add Pimoroni Pico LiPo 16MB
- boards: add Pimoroni Tiny 2040
- CMakeLists.txt: allow a board's cmake to set the manifest path
- enable MICROPY_PY_FSTRINGS by default
- Makefile: add "submodules" target, to match other ports
- rp2_flash: disable IRQs while calling flash_erase/program
- CMakeLists.txt: add option to enable double tap reset to bootrom
- mpconfigport.h: allow boards to add root pointers
samd port:
- add support for building with user C modules
stm32 port:
- softtimer: add soft_timer_reinsert() helper function
- mpbthciport: change from systick to soft-timer for BT scheduling
- provide a custom BTstack runloop that integrates with soft timer
- usb: make irq's default trigger enable all events
- boardctrl: skip running main.py if boot.py had an error
- sdio: fix undefined reference to DMA stream on H7
- dma: add DMAMUX configuration for H7 to fix dma_nohal_init
- main: call mp_deinit() at end of main
- adc: allow using ADC12 and ADC3 for H7
- adc: define the ADC instance used for internal channels
- adc: simplify and generalise how pin_adcX table is defined
- add new machine.I2S class for I2S protocol support
- boards/NUCLEO_F446RE: fix I2C1 pin assignment to match datasheet
- replace master/slave with controller/peripheral in I2C and SPI
- systick: always POLL_HOOK when delaying for milliseconds
- sdram: make SDRAM test cache aware, and optional failure with msg
- boards/NUCLEO_F446RE: enable CAN bus support
- boards: add support for SparkFun STM32 MicroMod Processor board
- uart: fix LPUART1 baudrate set/get
- uart: support low baudrates on LPUART1
- boards/STM32F429DISC: set correct UART2 pins and add UART3/6
- boards/NUCLEO_F439ZI: add board definition for NUCLEO_F439ZI
- boards/LEGO_HUB_NO6: add board definition for LEGO_HUB_NO6
- Makefile: update to only pull in used Bluetooth library
- README.md: update supported MCUs, and submodule and mboot use
- usbd_desc: rename USBD_xxx descriptor opts to MICROPY_HW_USB_xxx
- usbd_cdc_interface: rename USBD_CDC_xx opts to MICROPY_HW_USB_xx
- powerctrl: support changing frequency on WB MCUs
- boards/NUCLEO_H743ZI2: add modified version of NUCLEO_H743ZI
- mbedtls: fix compile warning about uninitialized val
- enable MICROPY_PY_FSTRINGS by default
- add implementation of machine.bitstream
- Makefile: allow GIT_SUBMODULES and LIBS to be extended
- stm32_it: support TIM17 IRQs on WB MCUs
- disable computed goto on constrained boards
- storage: make extended-block-device more configurable
- boards/LEGO_HUB_NO6: change SPI flash storage to use hardware SPI
- boards/LEGO_HUB_NO6: skip first 1MiB of SPI flash for storage
- boards/LEGO_HUB_NO6: add make commands to backup/restore firmware
teensy port: no changes specific to this component/port
unix port:
- modffi: add option to lock GC in callback, and cfun access
- Makefile: add back LIB_SRC_C to list of object files
- variants: enable help and help("modules") on standard and dev
- Makefile: disable error compression on arm-linux-gnueabi-gcc
windows port:
- Makefile: add .exe extension to executables name
- appveyor: update to VS 2017 and use Python 3.8 for build/test
zephyr port:
- machine_spi: add support for hardware SPI
2021-10-14 15:38:41 -04:00
STATIC mp_obj_t _EVE_make_new ( const mp_obj_type_t * type , size_t n_args , size_t n_kw , const mp_obj_t * args ) {
2020-02-03 19:46:14 -05:00
// mp_arg_check_num(n_args, kw_args, 1, 1, false);
2023-08-07 20:45:57 -04:00
mp_obj__EVE_t * o = mp_obj_malloc ( mp_obj__EVE_t , & _EVE_type ) ;
2020-02-07 13:30:49 -05:00
o - > _eve . n = 0 ;
o - > _eve . vscale = 16 ;
2020-02-05 20:58:59 -05:00
return MP_OBJ_FROM_PTR ( o ) ;
2020-02-03 19:46:14 -05:00
}
2023-09-19 21:09:29 -04:00
STATIC MP_DEFINE_CONST_OBJ_TYPE (
_EVE_type ,
MP_QSTR__EVE ,
MP_TYPE_FLAG_NONE ,
make_new , _EVE_make_new ,
locals_dict , & _EVE_locals_dict
) ;
2020-02-03 19:46:14 -05:00
2020-02-05 21:17:58 -05:00
STATIC const mp_rom_map_elem_t mp_module__eve_globals_table [ ] = {
{ MP_ROM_QSTR ( MP_QSTR___name__ ) , MP_ROM_QSTR ( MP_QSTR__eve ) } ,
{ MP_ROM_QSTR ( MP_QSTR__EVE ) , MP_OBJ_FROM_PTR ( & _EVE_type ) } ,
2020-02-03 19:46:14 -05:00
} ;
2020-02-05 21:17:58 -05:00
STATIC MP_DEFINE_CONST_DICT ( mp_module__eve_globals , mp_module__eve_globals_table ) ;
2020-02-03 19:46:14 -05:00
2020-02-05 21:17:58 -05:00
const mp_obj_module_t _eve_module = {
2020-02-03 19:46:14 -05:00
. base = { & mp_type_module } ,
2021-03-15 09:57:36 -04:00
. globals = ( mp_obj_dict_t * ) & mp_module__eve_globals ,
2020-02-03 19:46:14 -05:00
} ;
Convert more modules to use MP_REGISTER_MODULE
Convert _eve, _pew, aesio, alarm, audiopwmio, bitops, camera, canio, dualbank, gnss, i2cperipheral, imagecapture, ipaddress, memorymonitor, sdioio, socketpool, ssl, uheap, ustack, watchdog, and wifi modules to use MP_REGISTER_MODULE.
Related to #5183.
2021-09-01 00:12:00 -04:00
2023-08-07 20:45:57 -04:00
MP_REGISTER_MODULE ( MP_QSTR__eve , _eve_module ) ;