@@ -46,6 +46,14 @@ static mp_obj_t _register(mp_obj_t self, mp_obj_t o) {
4646}
4747static MP_DEFINE_CONST_FUN_OBJ_2 (register_obj , _register ) ;
4848
49+ //| def setmodel(self, m: int) -> None: ...
50+ static mp_obj_t _setmodel (mp_obj_t self , mp_obj_t m ) {
51+ common_hal__eve_t * eve = EVEHAL (self );
52+ eve -> model = mp_obj_get_int_truncated (m );
53+ return mp_const_none ;
54+ }
55+ static MP_DEFINE_CONST_FUN_OBJ_2 (setmodel_obj , _setmodel ) ;
56+
4957//| def flush(self) -> None:
5058//| """Send any queued drawing commands directly to the hardware.
5159//|
@@ -247,24 +255,39 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitmapswizzle_obj, 5, 5, _bitmapswizz
247255//| """
248256//| ...
249257
250- static void _transform (uint32_t * p , uint32_t * v , mp_obj_t a0 ) {
251- mp_float_t a = mp_obj_get_float (a0 );
258+ static void _transform1 (uint32_t * p , uint32_t * v , size_t n_args , const mp_obj_t * args ) {
259+ common_hal__eve_t * eve = EVEHAL (args [0 ]);
260+ mp_float_t a ;
252261
253- if ((-2.0 <= a ) && (a < 2.0 )) {
254- * p = 1 ;
255- * v = (int )(32768.0 * a );
262+ if (eve -> model == 0 ) {
263+ // Backwards-compatible case for legacy code
264+ if (n_args != 3 ) {
265+ mp_raise_TypeError (MP_ERROR_TEXT ("2 arguments expected" ));
266+ }
267+ * p = mp_obj_get_int_truncated (args [1 ]);
268+ * v = mp_obj_get_int_truncated (args [2 ]);
256269 } else {
257- * p = 0 ;
258- * v = (int )(256.0 * a );
270+ if (n_args != 2 ) {
271+ mp_raise_TypeError (MP_ERROR_TEXT ("1 argument expected" ));
272+ }
273+ a = mp_obj_get_float (args [1 ]);
274+ if ((eve -> model > 810 ) && (-2.0 <= a ) && (a < 2.0 )) {
275+ * p = 1 ;
276+ * v = (int )(32768.0 * a );
277+ } else {
278+ * p = 0 ;
279+ * v = (int )(256.0 * a );
280+ }
259281 }
260282}
261- static mp_obj_t _bitmaptransforma (mp_obj_t self , mp_obj_t a0 ) {
283+
284+ static mp_obj_t _bitmaptransforma (size_t n_args , const mp_obj_t * args ) {
262285 uint32_t p , v ;
263- _transform (& p , & v , a0 );
264- common_hal__eve_BitmapTransformA (EVEHAL (self ), p , v );
286+ _transform1 (& p , & v , n_args , args );
287+ common_hal__eve_BitmapTransformA (EVEHAL (args [ 0 ] ), p , v );
265288 return mp_const_none ;
266289}
267- static MP_DEFINE_CONST_FUN_OBJ_2 (bitmaptransforma_obj , _bitmaptransforma ) ;
290+ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN (bitmaptransforma_obj , 1 , 2 , _bitmaptransforma ) ;
268291
269292//| def BitmapTransformB(self, v: float) -> None:
270293//| """Set the :math:`b` component of the bitmap transform matrix
@@ -277,13 +300,13 @@ static MP_DEFINE_CONST_FUN_OBJ_2(bitmaptransforma_obj, _bitmaptransforma);
277300//| """
278301//| ...
279302
280- static mp_obj_t _bitmaptransformb (mp_obj_t self , mp_obj_t a0 ) {
303+ static mp_obj_t _bitmaptransformb (size_t n_args , const mp_obj_t * args ) {
281304 uint32_t p , v ;
282- _transform (& p , & v , a0 );
283- common_hal__eve_BitmapTransformB (EVEHAL (self ), p , v );
305+ _transform1 (& p , & v , n_args , args );
306+ common_hal__eve_BitmapTransformB (EVEHAL (args [ 0 ] ), p , v );
284307 return mp_const_none ;
285308}
286- static MP_DEFINE_CONST_FUN_OBJ_2 (bitmaptransformb_obj , _bitmaptransformb ) ;
309+ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN (bitmaptransformb_obj , 1 , 2 , _bitmaptransformb ) ;
287310
288311//| def BitmapTransformC(self, v: float) -> None:
289312//| """Set the :math:`c` component of the bitmap transform matrix
@@ -297,8 +320,15 @@ static MP_DEFINE_CONST_FUN_OBJ_2(bitmaptransformb_obj, _bitmaptransformb);
297320//| ...
298321
299322static mp_obj_t _bitmaptransformc (mp_obj_t self , mp_obj_t a0 ) {
300- mp_float_t v = mp_obj_get_float (a0 );
301- common_hal__eve_BitmapTransformC (EVEHAL (self ), (int )(256.0 * v ));
323+ common_hal__eve_t * eve = EVEHAL (self );
324+ int v ;
325+
326+ if (eve -> model == 0 ) {
327+ v = mp_obj_get_int_truncated (a0 );
328+ } else {
329+ v = (int )(256.0 * mp_obj_get_float (a0 ));
330+ }
331+ common_hal__eve_BitmapTransformC (EVEHAL (self ), v );
302332 return mp_const_none ;
303333}
304334static MP_DEFINE_CONST_FUN_OBJ_2 (bitmaptransformc_obj , _bitmaptransformc ) ;
@@ -314,13 +344,13 @@ static MP_DEFINE_CONST_FUN_OBJ_2(bitmaptransformc_obj, _bitmaptransformc);
314344//| """
315345//| ...
316346
317- static mp_obj_t _bitmaptransformd (mp_obj_t self , mp_obj_t a0 ) {
347+ static mp_obj_t _bitmaptransformd (size_t n_args , const mp_obj_t * args ) {
318348 uint32_t p , v ;
319- _transform (& p , & v , a0 );
320- common_hal__eve_BitmapTransformD (EVEHAL (self ), p , v );
349+ _transform1 (& p , & v , n_args , args );
350+ common_hal__eve_BitmapTransformD (EVEHAL (args [ 0 ] ), p , v );
321351 return mp_const_none ;
322352}
323- static MP_DEFINE_CONST_FUN_OBJ_2 (bitmaptransformd_obj , _bitmaptransformd ) ;
353+ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN (bitmaptransformd_obj , 1 , 2 , _bitmaptransformd ) ;
324354
325355//| def BitmapTransformE(self, v: float) -> None:
326356//| """Set the :math:`e` component of the bitmap transform matrix
@@ -333,13 +363,13 @@ static MP_DEFINE_CONST_FUN_OBJ_2(bitmaptransformd_obj, _bitmaptransformd);
333363//| """
334364//| ...
335365
336- static mp_obj_t _bitmaptransforme (mp_obj_t self , mp_obj_t a0 ) {
366+ static mp_obj_t _bitmaptransforme (size_t n_args , const mp_obj_t * args ) {
337367 uint32_t p , v ;
338- _transform (& p , & v , a0 );
339- common_hal__eve_BitmapTransformE (EVEHAL (self ), p , v );
368+ _transform1 (& p , & v , n_args , args );
369+ common_hal__eve_BitmapTransformE (EVEHAL (args [ 0 ] ), p , v );
340370 return mp_const_none ;
341371}
342- static MP_DEFINE_CONST_FUN_OBJ_2 (bitmaptransforme_obj , _bitmaptransforme ) ;
372+ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN (bitmaptransforme_obj , 1 , 2 , _bitmaptransforme ) ;
343373
344374//| def BitmapTransformF(self, v: int) -> None:
345375//| """Set the :math:`f` component of the bitmap transform matrix
@@ -353,8 +383,15 @@ static MP_DEFINE_CONST_FUN_OBJ_2(bitmaptransforme_obj, _bitmaptransforme);
353383//| ...
354384
355385static mp_obj_t _bitmaptransformf (mp_obj_t self , mp_obj_t a0 ) {
356- mp_float_t v = mp_obj_get_float (a0 );
357- common_hal__eve_BitmapTransformF (EVEHAL (self ), (int )(256.0 * v ));
386+ common_hal__eve_t * eve = EVEHAL (self );
387+ int v ;
388+
389+ if (eve -> model == 0 ) {
390+ v = mp_obj_get_int_truncated (a0 );
391+ } else {
392+ v = (int )(256.0 * mp_obj_get_float (a0 ));
393+ }
394+ common_hal__eve_BitmapTransformF (EVEHAL (self ), v );
358395 return mp_const_none ;
359396}
360397static MP_DEFINE_CONST_FUN_OBJ_2 (bitmaptransformf_obj , _bitmaptransformf ) ;
@@ -1068,6 +1105,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(cmd_obj, 4, 4, _cmd);
10681105
10691106static const mp_rom_map_elem_t _EVE_locals_dict_table [] = {
10701107 { MP_ROM_QSTR (MP_QSTR_register ), MP_ROM_PTR (& register_obj ) },
1108+ { MP_ROM_QSTR (MP_QSTR_setmodel ), MP_ROM_PTR (& setmodel_obj ) },
10711109 { MP_ROM_QSTR (MP_QSTR_cc ), MP_ROM_PTR (& cc_obj ) },
10721110 { MP_ROM_QSTR (MP_QSTR_flush ), MP_ROM_PTR (& flush_obj ) },
10731111 { MP_ROM_QSTR (MP_QSTR_Vertex2f ), MP_ROM_PTR (& vertex2f_obj ) },
@@ -1082,6 +1120,7 @@ static mp_obj_t _EVE_make_new(const mp_obj_type_t *type, size_t n_args, size_t n
10821120 mp_obj__EVE_t * o = mp_obj_malloc (mp_obj__EVE_t , & _EVE_type );
10831121 o -> _eve .n = 0 ;
10841122 o -> _eve .vscale = 16 ;
1123+ o -> _eve .model = 0 ; // default is legacy behavior
10851124 return MP_OBJ_FROM_PTR (o );
10861125}
10871126
0 commit comments