@@ -46,6 +46,14 @@ static mp_obj_t _register(mp_obj_t self, mp_obj_t o) {
46
46
}
47
47
static MP_DEFINE_CONST_FUN_OBJ_2 (register_obj , _register ) ;
48
48
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
+
49
57
//| def flush(self) -> None:
50
58
//| """Send any queued drawing commands directly to the hardware.
51
59
//|
@@ -247,24 +255,39 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitmapswizzle_obj, 5, 5, _bitmapswizz
247
255
//| """
248
256
//| ...
249
257
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 ;
252
261
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 ]);
256
269
} 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
+ }
259
281
}
260
282
}
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 ) {
262
285
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 );
265
288
return mp_const_none ;
266
289
}
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 ) ;
268
291
269
292
//| def BitmapTransformB(self, v: float) -> None:
270
293
//| """Set the :math:`b` component of the bitmap transform matrix
@@ -277,13 +300,13 @@ static MP_DEFINE_CONST_FUN_OBJ_2(bitmaptransforma_obj, _bitmaptransforma);
277
300
//| """
278
301
//| ...
279
302
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 ) {
281
304
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 );
284
307
return mp_const_none ;
285
308
}
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 ) ;
287
310
288
311
//| def BitmapTransformC(self, v: float) -> None:
289
312
//| """Set the :math:`c` component of the bitmap transform matrix
@@ -297,8 +320,15 @@ static MP_DEFINE_CONST_FUN_OBJ_2(bitmaptransformb_obj, _bitmaptransformb);
297
320
//| ...
298
321
299
322
static 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 );
302
332
return mp_const_none ;
303
333
}
304
334
static MP_DEFINE_CONST_FUN_OBJ_2 (bitmaptransformc_obj , _bitmaptransformc ) ;
@@ -314,13 +344,13 @@ static MP_DEFINE_CONST_FUN_OBJ_2(bitmaptransformc_obj, _bitmaptransformc);
314
344
//| """
315
345
//| ...
316
346
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 ) {
318
348
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 );
321
351
return mp_const_none ;
322
352
}
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 ) ;
324
354
325
355
//| def BitmapTransformE(self, v: float) -> None:
326
356
//| """Set the :math:`e` component of the bitmap transform matrix
@@ -333,13 +363,13 @@ static MP_DEFINE_CONST_FUN_OBJ_2(bitmaptransformd_obj, _bitmaptransformd);
333
363
//| """
334
364
//| ...
335
365
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 ) {
337
367
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 );
340
370
return mp_const_none ;
341
371
}
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 ) ;
343
373
344
374
//| def BitmapTransformF(self, v: int) -> None:
345
375
//| """Set the :math:`f` component of the bitmap transform matrix
@@ -353,8 +383,15 @@ static MP_DEFINE_CONST_FUN_OBJ_2(bitmaptransforme_obj, _bitmaptransforme);
353
383
//| ...
354
384
355
385
static 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 );
358
395
return mp_const_none ;
359
396
}
360
397
static 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);
1068
1105
1069
1106
static const mp_rom_map_elem_t _EVE_locals_dict_table [] = {
1070
1107
{ MP_ROM_QSTR (MP_QSTR_register ), MP_ROM_PTR (& register_obj ) },
1108
+ { MP_ROM_QSTR (MP_QSTR_setmodel ), MP_ROM_PTR (& setmodel_obj ) },
1071
1109
{ MP_ROM_QSTR (MP_QSTR_cc ), MP_ROM_PTR (& cc_obj ) },
1072
1110
{ MP_ROM_QSTR (MP_QSTR_flush ), MP_ROM_PTR (& flush_obj ) },
1073
1111
{ 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
1082
1120
mp_obj__EVE_t * o = mp_obj_malloc (mp_obj__EVE_t , & _EVE_type );
1083
1121
o -> _eve .n = 0 ;
1084
1122
o -> _eve .vscale = 16 ;
1123
+ o -> _eve .model = 0 ; // default is legacy behavior
1085
1124
return MP_OBJ_FROM_PTR (o );
1086
1125
}
1087
1126
0 commit comments