diff --git a/lib/libesp32/Berry/default/be_leds_lib.c b/lib/libesp32/Berry/default/be_leds_lib.c index a4442df37..06e322c13 100644 --- a/lib/libesp32/Berry/default/be_leds_lib.c +++ b/lib/libesp32/Berry/default/be_leds_lib.c @@ -7,11 +7,41 @@ #ifdef USE_WS2812 /******************************************************************** -** Solidified function: get_pixel_color +** Solidified function: pixel_count ********************************************************************/ -be_local_closure(Leds_get_pixel_color, /* name */ +be_local_closure(Leds_matrix_pixel_count, /* name */ be_nested_proto( - 6, /* nstack */ + 3, /* nstack */ + 1, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 2]) { /* constants */ + /* K0 */ be_nested_str_literal("w"), + /* K1 */ be_nested_str_literal("h"), + }), + (be_nested_const_str("pixel_count", -1855836553, 11)), + ((bstring*) &be_const_str_input), + ( &(const binstruction[ 4]) { /* code */ + 0x88040100, // 0000 GETMBR R1 R0 K0 + 0x88080101, // 0001 GETMBR R2 R0 K1 + 0x08040202, // 0002 MUL R1 R1 R2 + 0x80040200, // 0003 RET 1 R1 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: set_alternate +********************************************************************/ +be_local_closure(Leds_matrix_set_alternate, /* name */ + be_nested_proto( + 2, /* nstack */ 2, /* argc */ 0, /* varg */ 0, /* has upvals */ @@ -20,16 +50,13 @@ be_local_closure(Leds_get_pixel_color, /* name */ NULL, /* no sub protos */ 1, /* has constants */ ( &(const bvalue[ 1]) { /* constants */ - /* K0 */ be_nested_str_literal("call_native"), + /* K0 */ be_nested_str_literal("alternate"), }), - (be_nested_const_str("get_pixel_color", 337490048, 15)), + (be_nested_const_str("set_alternate", 1709680562, 13)), ((bstring*) &be_const_str_input), - ( &(const binstruction[ 5]) { /* code */ - 0x8C080100, // 0000 GETMET R2 R0 K0 - 0x5412000A, // 0001 LDINT R4 11 - 0x5C140200, // 0002 MOVE R5 R1 - 0x7C080600, // 0003 CALL R2 3 - 0x80040400, // 0004 RET 1 R2 + ( &(const binstruction[ 2]) { /* code */ + 0x90020001, // 0000 SETMBR R0 K0 R1 + 0x80000000, // 0001 RET 0 }) ) ); @@ -37,11 +64,11 @@ be_local_closure(Leds_get_pixel_color, /* name */ /******************************************************************** -** Solidified function: pixels_buffer +** Solidified function: pixel_size ********************************************************************/ -be_local_closure(Leds_pixels_buffer, /* name */ +be_local_closure(Leds_matrix_pixel_size, /* name */ be_nested_proto( - 4, /* nstack */ + 3, /* nstack */ 1, /* argc */ 0, /* varg */ 0, /* has upvals */ @@ -49,15 +76,16 @@ be_local_closure(Leds_pixels_buffer, /* name */ 0, /* has sup protos */ NULL, /* no sub protos */ 1, /* has constants */ - ( &(const bvalue[ 1]) { /* constants */ - /* K0 */ be_nested_str_literal("call_native"), + ( &(const bvalue[ 2]) { /* constants */ + /* K0 */ be_nested_str_literal("strip"), + /* K1 */ be_nested_str_literal("pixel_size"), }), - (be_nested_const_str("pixels_buffer", 1229555807, 13)), + (be_nested_const_str("pixel_size", -2085831511, 10)), ((bstring*) &be_const_str_input), ( &(const binstruction[ 4]) { /* code */ - 0x8C040100, // 0000 GETMET R1 R0 K0 - 0x540E0005, // 0001 LDINT R3 6 - 0x7C040400, // 0002 CALL R1 2 + 0x88040100, // 0000 GETMBR R1 R0 K0 + 0x8C040301, // 0001 GETMET R1 R1 K1 + 0x7C040200, // 0002 CALL R1 1 0x80040200, // 0003 RET 1 R1 }) ) @@ -65,10 +93,232 @@ be_local_closure(Leds_pixels_buffer, /* name */ /*******************************************************************/ +/******************************************************************** +** Solidified function: set_pixel_color +********************************************************************/ +be_local_closure(Leds_matrix_set_pixel_color, /* name */ + be_nested_proto( + 9, /* nstack */ + 4, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 3]) { /* constants */ + /* K0 */ be_nested_str_literal("strip"), + /* K1 */ be_nested_str_literal("set_pixel_color"), + /* K2 */ be_nested_str_literal("offset"), + }), + (be_nested_const_str("set_pixel_color", 1275248356, 15)), + ((bstring*) &be_const_str_input), + ( &(const binstruction[ 8]) { /* code */ + 0x88100100, // 0000 GETMBR R4 R0 K0 + 0x8C100901, // 0001 GETMET R4 R4 K1 + 0x88180102, // 0002 GETMBR R6 R0 K2 + 0x00180206, // 0003 ADD R6 R1 R6 + 0x5C1C0400, // 0004 MOVE R7 R2 + 0x5C200600, // 0005 MOVE R8 R3 + 0x7C100800, // 0006 CALL R4 4 + 0x80000000, // 0007 RET 0 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: set_matrix_pixel_color +********************************************************************/ +be_local_closure(Leds_matrix_set_matrix_pixel_color, /* name */ + be_nested_proto( + 10, /* nstack */ + 5, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 8]) { /* constants */ + /* K0 */ be_nested_str_literal("alternate"), + /* K1 */ be_const_int(2), + /* K2 */ be_nested_str_literal("strip"), + /* K3 */ be_nested_str_literal("set_pixel_color"), + /* K4 */ be_nested_str_literal("w"), + /* K5 */ be_nested_str_literal("h"), + /* K6 */ be_const_int(1), + /* K7 */ be_nested_str_literal("offset"), + }), + (be_nested_const_str("set_matrix_pixel_color", 1197149462, 22)), + ((bstring*) &be_const_str_input), + ( &(const binstruction[29]) { /* code */ + 0x88140100, // 0000 GETMBR R5 R0 K0 + 0x7816000F, // 0001 JMPF R5 #0012 + 0x10140301, // 0002 MOD R5 R1 K1 + 0x7816000D, // 0003 JMPF R5 #0012 + 0x88140102, // 0004 GETMBR R5 R0 K2 + 0x8C140B03, // 0005 GETMET R5 R5 K3 + 0x881C0104, // 0006 GETMBR R7 R0 K4 + 0x081C0207, // 0007 MUL R7 R1 R7 + 0x88200105, // 0008 GETMBR R8 R0 K5 + 0x001C0E08, // 0009 ADD R7 R7 R8 + 0x041C0E02, // 000A SUB R7 R7 R2 + 0x041C0F06, // 000B SUB R7 R7 K6 + 0x88200107, // 000C GETMBR R8 R0 K7 + 0x001C0E08, // 000D ADD R7 R7 R8 + 0x5C200600, // 000E MOVE R8 R3 + 0x5C240800, // 000F MOVE R9 R4 + 0x7C140800, // 0010 CALL R5 4 + 0x70020009, // 0011 JMP #001C + 0x88140102, // 0012 GETMBR R5 R0 K2 + 0x8C140B03, // 0013 GETMET R5 R5 K3 + 0x881C0104, // 0014 GETMBR R7 R0 K4 + 0x081C0207, // 0015 MUL R7 R1 R7 + 0x001C0E02, // 0016 ADD R7 R7 R2 + 0x88200107, // 0017 GETMBR R8 R0 K7 + 0x001C0E08, // 0018 ADD R7 R7 R8 + 0x5C200600, // 0019 MOVE R8 R3 + 0x5C240800, // 001A MOVE R9 R4 + 0x7C140800, // 001B CALL R5 4 + 0x80000000, // 001C RET 0 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: show +********************************************************************/ +be_local_closure(Leds_matrix_show, /* name */ + be_nested_proto( + 4, /* nstack */ + 2, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 7]) { /* constants */ + /* K0 */ be_nested_str_literal("offset"), + /* K1 */ be_const_int(0), + /* K2 */ be_nested_str_literal("w"), + /* K3 */ be_nested_str_literal("h"), + /* K4 */ be_nested_str_literal("strip"), + /* K5 */ be_nested_str_literal("leds"), + /* K6 */ be_nested_str_literal("show"), + }), + (be_nested_const_str("show", -1454906820, 4)), + ((bstring*) &be_const_str_input), + ( &(const binstruction[18]) { /* code */ + 0x60080017, // 0000 GETGBL R2 G23 + 0x5C0C0200, // 0001 MOVE R3 R1 + 0x7C080200, // 0002 CALL R2 1 + 0x740A0009, // 0003 JMPT R2 #000E + 0x88080100, // 0004 GETMBR R2 R0 K0 + 0x1C080501, // 0005 EQ R2 R2 K1 + 0x780A0009, // 0006 JMPF R2 #0011 + 0x88080102, // 0007 GETMBR R2 R0 K2 + 0x880C0103, // 0008 GETMBR R3 R0 K3 + 0x08080403, // 0009 MUL R2 R2 R3 + 0x880C0104, // 000A GETMBR R3 R0 K4 + 0x880C0705, // 000B GETMBR R3 R3 K5 + 0x1C080403, // 000C EQ R2 R2 R3 + 0x780A0002, // 000D JMPF R2 #0011 + 0x88080104, // 000E GETMBR R2 R0 K4 + 0x8C080506, // 000F GETMET R2 R2 K6 + 0x7C080200, // 0010 CALL R2 1 + 0x80000000, // 0011 RET 0 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: is_dirty +********************************************************************/ +be_local_closure(Leds_matrix_is_dirty, /* name */ + be_nested_proto( + 3, /* nstack */ + 1, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 2]) { /* constants */ + /* K0 */ be_nested_str_literal("strip"), + /* K1 */ be_nested_str_literal("is_dirty"), + }), + (be_nested_const_str("is_dirty", 418034110, 8)), + ((bstring*) &be_const_str_input), + ( &(const binstruction[ 4]) { /* code */ + 0x88040100, // 0000 GETMBR R1 R0 K0 + 0x8C040301, // 0001 GETMET R1 R1 K1 + 0x7C040200, // 0002 CALL R1 1 + 0x80040200, // 0003 RET 1 R1 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: clear_to +********************************************************************/ +be_local_closure(Leds_matrix_clear_to, /* name */ + be_nested_proto( + 9, /* nstack */ + 3, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 7]) { /* constants */ + /* K0 */ be_const_int(0), + /* K1 */ be_nested_str_literal("w"), + /* K2 */ be_nested_str_literal("h"), + /* K3 */ be_nested_str_literal("strip"), + /* K4 */ be_nested_str_literal("set_pixel_color"), + /* K5 */ be_nested_str_literal("offset"), + /* K6 */ be_const_int(1), + }), + (be_nested_const_str("clear_to", -766965166, 8)), + ((bstring*) &be_const_str_input), + ( &(const binstruction[16]) { /* code */ + 0x580C0000, // 0000 LDCONST R3 K0 + 0x88100101, // 0001 GETMBR R4 R0 K1 + 0x88140102, // 0002 GETMBR R5 R0 K2 + 0x08100805, // 0003 MUL R4 R4 R5 + 0x14100604, // 0004 LT R4 R3 R4 + 0x78120008, // 0005 JMPF R4 #000F + 0x88100103, // 0006 GETMBR R4 R0 K3 + 0x8C100904, // 0007 GETMET R4 R4 K4 + 0x88180105, // 0008 GETMBR R6 R0 K5 + 0x00180606, // 0009 ADD R6 R3 R6 + 0x5C1C0200, // 000A MOVE R7 R1 + 0x5C200400, // 000B MOVE R8 R2 + 0x7C100800, // 000C CALL R4 4 + 0x000C0706, // 000D ADD R3 R3 K6 + 0x7001FFF1, // 000E JMP #0001 + 0x80000000, // 000F RET 0 + }) + ) +); +/*******************************************************************/ + + /******************************************************************** ** Solidified function: clear ********************************************************************/ -be_local_closure(Leds_clear, /* name */ +be_local_closure(Leds_matrix_clear, /* name */ be_nested_proto( 4, /* nstack */ 1, /* argc */ @@ -99,66 +349,24 @@ be_local_closure(Leds_clear, /* name */ /******************************************************************** -** Solidified function: init +** Solidified function: pixels_buffer ********************************************************************/ -be_local_closure(Leds_init, /* name */ +be_local_closure(Leds_matrix_pixels_buffer, /* name */ be_nested_proto( - 11, /* nstack */ - 5, /* argc */ + 2, /* nstack */ + 1, /* argc */ 0, /* varg */ 0, /* has upvals */ NULL, /* no upvals */ 0, /* has sup protos */ NULL, /* no sub protos */ - 1, /* has constants */ - ( &(const bvalue[11]) { /* constants */ - /* K0 */ be_nested_str_literal("gamma"), - /* K1 */ be_nested_str_literal("pin"), - /* K2 */ be_nested_str_literal("WS2812"), - /* K3 */ be_const_int(0), - /* K4 */ be_nested_str_literal("valuer_error"), - /* K5 */ be_nested_str_literal("no GPIO specified for neopixelbus"), - /* K6 */ be_nested_str_literal("ctor"), - /* K7 */ be_nested_str_literal("_p"), - /* K8 */ be_nested_str_literal("internal_error"), - /* K9 */ be_nested_str_literal("couldn't not initialize noepixelbus"), - /* K10 */ be_nested_str_literal("begin"), - }), - (be_nested_const_str("init", 380752755, 4)), + 0, /* has constants */ + NULL, /* no const */ + (be_nested_const_str("pixels_buffer", 1229555807, 13)), ((bstring*) &be_const_str_input), - ( &(const binstruction[32]) { /* code */ - 0x50140200, // 0000 LDBOOL R5 1 0 - 0x90020005, // 0001 SETMBR R0 K0 R5 - 0x4C140000, // 0002 LDNIL R5 - 0x1C140405, // 0003 EQ R5 R2 R5 - 0x78160008, // 0004 JMPF R5 #000E - 0x8C140501, // 0005 GETMET R5 R2 K1 - 0x881C0502, // 0006 GETMBR R7 R2 K2 - 0x7C140400, // 0007 CALL R5 2 - 0x28140B03, // 0008 GE R5 R5 K3 - 0x78160003, // 0009 JMPF R5 #000E - 0x8C140501, // 000A GETMET R5 R2 K1 - 0x881C0502, // 000B GETMBR R7 R2 K2 - 0x7C140400, // 000C CALL R5 2 - 0x5C080A00, // 000D MOVE R2 R5 - 0x4C140000, // 000E LDNIL R5 - 0x1C140405, // 000F EQ R5 R2 R5 - 0x78160000, // 0010 JMPF R5 #0012 - 0xB0060905, // 0011 RAISE 1 K4 K5 - 0x8C140106, // 0012 GETMET R5 R0 K6 - 0x5C1C0200, // 0013 MOVE R7 R1 - 0x5C200400, // 0014 MOVE R8 R2 - 0x5C240600, // 0015 MOVE R9 R3 - 0x5C280800, // 0016 MOVE R10 R4 - 0x7C140A00, // 0017 CALL R5 5 - 0x88140107, // 0018 GETMBR R5 R0 K7 - 0x4C180000, // 0019 LDNIL R6 - 0x1C140A06, // 001A EQ R5 R5 R6 - 0x78160000, // 001B JMPF R5 #001D - 0xB0061109, // 001C RAISE 1 K8 K9 - 0x8C14010A, // 001D GETMET R5 R0 K10 - 0x7C140200, // 001E CALL R5 1 - 0x80000000, // 001F RET 0 + ( &(const binstruction[ 2]) { /* code */ + 0x4C040000, // 0000 LDNIL R1 + 0x80040200, // 0001 RET 1 R1 }) ) ); @@ -166,12 +374,48 @@ be_local_closure(Leds_init, /* name */ /******************************************************************** -** Solidified function: set_pixel_color +** Solidified function: init ********************************************************************/ -be_local_closure(Leds_set_pixel_color, /* name */ +be_local_closure(Leds_matrix_init, /* name */ be_nested_proto( - 12, /* nstack */ - 4, /* argc */ + 6, /* nstack */ + 5, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 5]) { /* constants */ + /* K0 */ be_nested_str_literal("strip"), + /* K1 */ be_nested_str_literal("offset"), + /* K2 */ be_nested_str_literal("h"), + /* K3 */ be_nested_str_literal("w"), + /* K4 */ be_nested_str_literal("alternate"), + }), + (be_nested_const_str("init", 380752755, 4)), + ((bstring*) &be_const_str_input), + ( &(const binstruction[ 7]) { /* code */ + 0x90020001, // 0000 SETMBR R0 K0 R1 + 0x90020204, // 0001 SETMBR R0 K1 R4 + 0x90020403, // 0002 SETMBR R0 K2 R3 + 0x90020602, // 0003 SETMBR R0 K3 R2 + 0x50140000, // 0004 LDBOOL R5 0 0 + 0x90020805, // 0005 SETMBR R0 K4 R5 + 0x80000000, // 0006 RET 0 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: dirty +********************************************************************/ +be_local_closure(Leds_matrix_dirty, /* name */ + be_nested_proto( + 3, /* nstack */ + 1, /* argc */ 0, /* varg */ 0, /* has upvals */ NULL, /* no upvals */ @@ -179,21 +423,229 @@ be_local_closure(Leds_set_pixel_color, /* name */ NULL, /* no sub protos */ 1, /* has constants */ ( &(const bvalue[ 2]) { /* constants */ - /* K0 */ be_nested_str_literal("call_native"), - /* K1 */ be_nested_str_literal("to_gamma"), + /* K0 */ be_nested_str_literal("strip"), + /* K1 */ be_nested_str_literal("dirty"), }), - (be_nested_const_str("set_pixel_color", 1275248356, 15)), + (be_nested_const_str("dirty", -1627386213, 5)), ((bstring*) &be_const_str_input), - ( &(const binstruction[ 9]) { /* code */ - 0x8C100100, // 0000 GETMET R4 R0 K0 - 0x541A0009, // 0001 LDINT R6 10 - 0x5C1C0200, // 0002 MOVE R7 R1 - 0x8C200101, // 0003 GETMET R8 R0 K1 - 0x5C280400, // 0004 MOVE R10 R2 - 0x5C2C0600, // 0005 MOVE R11 R3 - 0x7C200600, // 0006 CALL R8 3 - 0x7C100800, // 0007 CALL R4 4 - 0x80000000, // 0008 RET 0 + ( &(const binstruction[ 4]) { /* code */ + 0x88040100, // 0000 GETMBR R1 R0 K0 + 0x8C040301, // 0001 GETMET R1 R1 K1 + 0x7C040200, // 0002 CALL R1 1 + 0x80000000, // 0003 RET 0 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: get_pixel_color +********************************************************************/ +be_local_closure(Leds_matrix_get_pixel_color, /* name */ + be_nested_proto( + 5, /* nstack */ + 2, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 3]) { /* constants */ + /* K0 */ be_nested_str_literal("strip"), + /* K1 */ be_nested_str_literal("get_pixel_color"), + /* K2 */ be_nested_str_literal("offseta"), + }), + (be_nested_const_str("get_pixel_color", 337490048, 15)), + ((bstring*) &be_const_str_input), + ( &(const binstruction[ 6]) { /* code */ + 0x88080100, // 0000 GETMBR R2 R0 K0 + 0x8C080501, // 0001 GETMET R2 R2 K1 + 0x88100102, // 0002 GETMBR R4 R0 K2 + 0x00100204, // 0003 ADD R4 R1 R4 + 0x7C080400, // 0004 CALL R2 2 + 0x80040400, // 0005 RET 1 R2 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: get_alternate +********************************************************************/ +be_local_closure(Leds_matrix_get_alternate, /* name */ + be_nested_proto( + 2, /* nstack */ + 1, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 1]) { /* constants */ + /* K0 */ be_nested_str_literal("alternate"), + }), + (be_nested_const_str("get_alternate", 1450148894, 13)), + ((bstring*) &be_const_str_input), + ( &(const binstruction[ 2]) { /* code */ + 0x88040100, // 0000 GETMBR R1 R0 K0 + 0x80040200, // 0001 RET 1 R1 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: begin +********************************************************************/ +be_local_closure(Leds_matrix_begin, /* name */ + be_nested_proto( + 1, /* nstack */ + 1, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 0, /* has constants */ + NULL, /* no const */ + (be_nested_const_str("begin", 1748273790, 5)), + ((bstring*) &be_const_str_input), + ( &(const binstruction[ 1]) { /* code */ + 0x80000000, // 0000 RET 0 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: can_show +********************************************************************/ +be_local_closure(Leds_matrix_can_show, /* name */ + be_nested_proto( + 3, /* nstack */ + 1, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 2]) { /* constants */ + /* K0 */ be_nested_str_literal("strip"), + /* K1 */ be_nested_str_literal("can_show"), + }), + (be_nested_const_str("can_show", 960091187, 8)), + ((bstring*) &be_const_str_input), + ( &(const binstruction[ 4]) { /* code */ + 0x88040100, // 0000 GETMBR R1 R0 K0 + 0x8C040301, // 0001 GETMET R1 R1 K1 + 0x7C040200, // 0002 CALL R1 1 + 0x80040200, // 0003 RET 1 R1 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified class: Leds_matrix +********************************************************************/ +be_local_class(Leds_matrix, + 5, + NULL, + be_nested_map(21, + ( (struct bmapnode*) &(const bmapnode[]) { + { be_nested_key("pixel_count", -1855836553, 11, -1), be_const_closure(Leds_matrix_pixel_count_closure) }, + { be_nested_key("h", -317966505, 1, 6), be_const_var(2) }, + { be_nested_key("set_alternate", 1709680562, 13, 7), be_const_closure(Leds_matrix_set_alternate_closure) }, + { be_nested_key("pixel_size", -2085831511, 10, 16), be_const_closure(Leds_matrix_pixel_size_closure) }, + { be_nested_key("set_pixel_color", 1275248356, 15, 19), be_const_closure(Leds_matrix_set_pixel_color_closure) }, + { be_nested_key("set_matrix_pixel_color", 1197149462, 22, 10), be_const_closure(Leds_matrix_set_matrix_pixel_color_closure) }, + { be_nested_key("show", -1454906820, 4, -1), be_const_closure(Leds_matrix_show_closure) }, + { be_nested_key("alternate", 1140253277, 9, -1), be_const_var(4) }, + { be_nested_key("strip", -48555823, 5, -1), be_const_var(0) }, + { be_nested_key("clear_to", -766965166, 8, -1), be_const_closure(Leds_matrix_clear_to_closure) }, + { be_nested_key("w", -234078410, 1, 15), be_const_var(3) }, + { be_nested_key("pixels_buffer", 1229555807, 13, -1), be_const_closure(Leds_matrix_pixels_buffer_closure) }, + { be_nested_key("init", 380752755, 4, -1), be_const_closure(Leds_matrix_init_closure) }, + { be_nested_key("dirty", -1627386213, 5, -1), be_const_closure(Leds_matrix_dirty_closure) }, + { be_nested_key("get_pixel_color", 337490048, 15, -1), be_const_closure(Leds_matrix_get_pixel_color_closure) }, + { be_nested_key("get_alternate", 1450148894, 13, 17), be_const_closure(Leds_matrix_get_alternate_closure) }, + { be_nested_key("offset", 348705738, 6, 8), be_const_var(1) }, + { be_nested_key("clear", 1550717474, 5, -1), be_const_closure(Leds_matrix_clear_closure) }, + { be_nested_key("begin", 1748273790, 5, -1), be_const_closure(Leds_matrix_begin_closure) }, + { be_nested_key("is_dirty", 418034110, 8, -1), be_const_closure(Leds_matrix_is_dirty_closure) }, + { be_nested_key("can_show", 960091187, 8, -1), be_const_closure(Leds_matrix_can_show_closure) }, + })), + be_str_literal("Leds_matrix") +); + +/******************************************************************** +** Solidified function: create_matrix +********************************************************************/ +be_local_closure(Leds_create_matrix, /* name */ + be_nested_proto( + 10, /* nstack */ + 4, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 5]) { /* constants */ + /* K0 */ be_const_int(0), + /* K1 */ be_nested_str_literal("leds"), + /* K2 */ be_nested_str_literal("value_error"), + /* K3 */ be_nested_str_literal("out of range"), + /* K4 */ be_const_class(be_class_Leds_matrix), + }), + (be_nested_const_str("create_matrix", -766781373, 13)), + ((bstring*) &be_const_str_input), + ( &(const binstruction[37]) { /* code */ + 0x60100009, // 0000 GETGBL R4 G9 + 0x5C140600, // 0001 MOVE R5 R3 + 0x7C100200, // 0002 CALL R4 1 + 0x5C0C0800, // 0003 MOVE R3 R4 + 0x60100009, // 0004 GETGBL R4 G9 + 0x5C140200, // 0005 MOVE R5 R1 + 0x7C100200, // 0006 CALL R4 1 + 0x5C040800, // 0007 MOVE R1 R4 + 0x60100009, // 0008 GETGBL R4 G9 + 0x5C140400, // 0009 MOVE R5 R2 + 0x7C100200, // 000A CALL R4 1 + 0x5C080800, // 000B MOVE R2 R4 + 0x4C100000, // 000C LDNIL R4 + 0x1C100604, // 000D EQ R4 R3 R4 + 0x78120000, // 000E JMPF R4 #0010 + 0x580C0000, // 000F LDCONST R3 K0 + 0x08100202, // 0010 MUL R4 R1 R2 + 0x00100803, // 0011 ADD R4 R4 R3 + 0x88140101, // 0012 GETMBR R5 R0 K1 + 0x24100805, // 0013 GT R4 R4 R5 + 0x74120005, // 0014 JMPT R4 #001B + 0x14100500, // 0015 LT R4 R2 K0 + 0x74120003, // 0016 JMPT R4 #001B + 0x14100300, // 0017 LT R4 R1 K0 + 0x74120001, // 0018 JMPT R4 #001B + 0x14100700, // 0019 LT R4 R3 K0 + 0x78120000, // 001A JMPF R4 #001C + 0xB0060503, // 001B RAISE 1 K2 K3 + 0x58100004, // 001C LDCONST R4 K4 + 0xB4000004, // 001D CLASS K4 + 0x5C140800, // 001E MOVE R5 R4 + 0x5C180000, // 001F MOVE R6 R0 + 0x5C1C0200, // 0020 MOVE R7 R1 + 0x5C200400, // 0021 MOVE R8 R2 + 0x5C240600, // 0022 MOVE R9 R3 + 0x7C140800, // 0023 CALL R5 4 + 0x80040A00, // 0024 RET 1 R5 }) ) ); @@ -358,29 +810,37 @@ be_local_closure(Leds_pixel_count, /* name */ /******************************************************************** -** Solidified function: can_show +** Solidified function: matrix ********************************************************************/ -be_local_closure(Leds_can_show, /* name */ +be_local_closure(Leds_matrix, /* name */ be_nested_proto( - 4, /* nstack */ - 1, /* argc */ + 10, /* nstack */ + 4, /* argc */ 0, /* varg */ 0, /* has upvals */ NULL, /* no upvals */ 0, /* has sup protos */ NULL, /* no sub protos */ 1, /* has constants */ - ( &(const bvalue[ 2]) { /* constants */ - /* K0 */ be_nested_str_literal("call_native"), - /* K1 */ be_const_int(3), + ( &(const bvalue[ 3]) { /* constants */ + /* K0 */ be_nested_str_literal("Leds"), + /* K1 */ be_nested_str_literal("create_matrix"), + /* K2 */ be_const_int(0), }), - (be_nested_const_str("can_show", 960091187, 8)), + (be_nested_const_str("matrix", 365099244, 6)), ((bstring*) &be_const_str_input), - ( &(const binstruction[ 4]) { /* code */ - 0x8C040100, // 0000 GETMET R1 R0 K0 - 0x580C0001, // 0001 LDCONST R3 K1 - 0x7C040400, // 0002 CALL R1 2 - 0x80040200, // 0003 RET 1 R1 + ( &(const binstruction[11]) { /* code */ + 0xB8120000, // 0000 GETNGBL R4 K0 + 0x08140001, // 0001 MUL R5 R0 R1 + 0x5C180400, // 0002 MOVE R6 R2 + 0x5C1C0600, // 0003 MOVE R7 R3 + 0x7C100600, // 0004 CALL R4 3 + 0x8C140901, // 0005 GETMET R5 R4 K1 + 0x5C1C0000, // 0006 MOVE R7 R0 + 0x5C200200, // 0007 MOVE R8 R1 + 0x58240002, // 0008 LDCONST R9 K2 + 0x7C140800, // 0009 CALL R5 4 + 0x80040A00, // 000A RET 1 R5 }) ) ); @@ -417,9 +877,9 @@ be_local_closure(Leds_pixel_size, /* name */ /******************************************************************** -** Solidified function: dirty +** Solidified function: pixels_buffer ********************************************************************/ -be_local_closure(Leds_dirty, /* name */ +be_local_closure(Leds_pixels_buffer, /* name */ be_nested_proto( 4, /* nstack */ 1, /* argc */ @@ -432,13 +892,13 @@ be_local_closure(Leds_dirty, /* name */ ( &(const bvalue[ 1]) { /* constants */ /* K0 */ be_nested_str_literal("call_native"), }), - (be_nested_const_str("dirty", -1627386213, 5)), + (be_nested_const_str("pixels_buffer", 1229555807, 13)), ((bstring*) &be_const_str_input), ( &(const binstruction[ 4]) { /* code */ 0x8C040100, // 0000 GETMET R1 R0 K0 - 0x540E0004, // 0001 LDINT R3 5 + 0x540E0005, // 0001 LDINT R3 6 0x7C040400, // 0002 CALL R1 2 - 0x80000000, // 0003 RET 0 + 0x80040200, // 0003 RET 1 R1 }) ) ); @@ -446,9 +906,74 @@ be_local_closure(Leds_dirty, /* name */ /******************************************************************** -** Solidified function: show +** Solidified function: get_pixel_color ********************************************************************/ -be_local_closure(Leds_show, /* name */ +be_local_closure(Leds_get_pixel_color, /* name */ + be_nested_proto( + 6, /* nstack */ + 2, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 1]) { /* constants */ + /* K0 */ be_nested_str_literal("call_native"), + }), + (be_nested_const_str("get_pixel_color", 337490048, 15)), + ((bstring*) &be_const_str_input), + ( &(const binstruction[ 5]) { /* code */ + 0x8C080100, // 0000 GETMET R2 R0 K0 + 0x5412000A, // 0001 LDINT R4 11 + 0x5C140200, // 0002 MOVE R5 R1 + 0x7C080600, // 0003 CALL R2 3 + 0x80040400, // 0004 RET 1 R2 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: set_pixel_color +********************************************************************/ +be_local_closure(Leds_set_pixel_color, /* name */ + be_nested_proto( + 12, /* nstack */ + 4, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 2]) { /* constants */ + /* K0 */ be_nested_str_literal("call_native"), + /* K1 */ be_nested_str_literal("to_gamma"), + }), + (be_nested_const_str("set_pixel_color", 1275248356, 15)), + ((bstring*) &be_const_str_input), + ( &(const binstruction[ 9]) { /* code */ + 0x8C100100, // 0000 GETMET R4 R0 K0 + 0x541A0009, // 0001 LDINT R6 10 + 0x5C1C0200, // 0002 MOVE R7 R1 + 0x8C200101, // 0003 GETMET R8 R0 K1 + 0x5C280400, // 0004 MOVE R10 R2 + 0x5C2C0600, // 0005 MOVE R11 R3 + 0x7C200600, // 0006 CALL R8 3 + 0x7C100800, // 0007 CALL R4 4 + 0x80000000, // 0008 RET 0 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: is_dirty +********************************************************************/ +be_local_closure(Leds_is_dirty, /* name */ be_nested_proto( 4, /* nstack */ 1, /* argc */ @@ -458,17 +983,88 @@ be_local_closure(Leds_show, /* name */ 0, /* has sup protos */ NULL, /* no sub protos */ 1, /* has constants */ - ( &(const bvalue[ 2]) { /* constants */ + ( &(const bvalue[ 1]) { /* constants */ /* K0 */ be_nested_str_literal("call_native"), - /* K1 */ be_const_int(2), }), - (be_nested_const_str("show", -1454906820, 4)), + (be_nested_const_str("is_dirty", 418034110, 8)), ((bstring*) &be_const_str_input), ( &(const binstruction[ 4]) { /* code */ 0x8C040100, // 0000 GETMET R1 R0 K0 - 0x580C0001, // 0001 LDCONST R3 K1 + 0x540E0003, // 0001 LDINT R3 4 0x7C040400, // 0002 CALL R1 2 - 0x80000000, // 0003 RET 0 + 0x80040200, // 0003 RET 1 R1 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: init +********************************************************************/ +be_local_closure(Leds_init, /* name */ + be_nested_proto( + 11, /* nstack */ + 5, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[12]) { /* constants */ + /* K0 */ be_nested_str_literal("gamma"), + /* K1 */ be_nested_str_literal("leds"), + /* K2 */ be_nested_str_literal("pin"), + /* K3 */ be_nested_str_literal("WS2812"), + /* K4 */ be_const_int(0), + /* K5 */ be_nested_str_literal("valuer_error"), + /* K6 */ be_nested_str_literal("no GPIO specified for neopixelbus"), + /* K7 */ be_nested_str_literal("ctor"), + /* K8 */ be_nested_str_literal("_p"), + /* K9 */ be_nested_str_literal("internal_error"), + /* K10 */ be_nested_str_literal("couldn't not initialize noepixelbus"), + /* K11 */ be_nested_str_literal("begin"), + }), + (be_nested_const_str("init", 380752755, 4)), + ((bstring*) &be_const_str_input), + ( &(const binstruction[36]) { /* code */ + 0x50140200, // 0000 LDBOOL R5 1 0 + 0x90020005, // 0001 SETMBR R0 K0 R5 + 0x60140009, // 0002 GETGBL R5 G9 + 0x5C180200, // 0003 MOVE R6 R1 + 0x7C140200, // 0004 CALL R5 1 + 0x90020205, // 0005 SETMBR R0 K1 R5 + 0x4C140000, // 0006 LDNIL R5 + 0x1C140405, // 0007 EQ R5 R2 R5 + 0x78160008, // 0008 JMPF R5 #0012 + 0x8C140502, // 0009 GETMET R5 R2 K2 + 0x881C0503, // 000A GETMBR R7 R2 K3 + 0x7C140400, // 000B CALL R5 2 + 0x28140B04, // 000C GE R5 R5 K4 + 0x78160003, // 000D JMPF R5 #0012 + 0x8C140502, // 000E GETMET R5 R2 K2 + 0x881C0503, // 000F GETMBR R7 R2 K3 + 0x7C140400, // 0010 CALL R5 2 + 0x5C080A00, // 0011 MOVE R2 R5 + 0x4C140000, // 0012 LDNIL R5 + 0x1C140405, // 0013 EQ R5 R2 R5 + 0x78160000, // 0014 JMPF R5 #0016 + 0xB0060B06, // 0015 RAISE 1 K5 K6 + 0x8C140107, // 0016 GETMET R5 R0 K7 + 0x881C0101, // 0017 GETMBR R7 R0 K1 + 0x5C200400, // 0018 MOVE R8 R2 + 0x5C240600, // 0019 MOVE R9 R3 + 0x5C280800, // 001A MOVE R10 R4 + 0x7C140A00, // 001B CALL R5 5 + 0x88140108, // 001C GETMBR R5 R0 K8 + 0x4C180000, // 001D LDNIL R6 + 0x1C140A06, // 001E EQ R5 R5 R6 + 0x78160000, // 001F JMPF R5 #0021 + 0xB006130A, // 0020 RAISE 1 K9 K10 + 0x8C14010B, // 0021 GETMET R5 R0 K11 + 0x7C140200, // 0022 CALL R5 1 + 0x80000000, // 0023 RET 0 }) ) ); @@ -510,9 +1106,9 @@ be_local_closure(Leds_clear_to, /* name */ /******************************************************************** -** Solidified function: is_dirty +** Solidified function: can_show ********************************************************************/ -be_local_closure(Leds_is_dirty, /* name */ +be_local_closure(Leds_can_show, /* name */ be_nested_proto( 4, /* nstack */ 1, /* argc */ @@ -522,14 +1118,15 @@ be_local_closure(Leds_is_dirty, /* name */ 0, /* has sup protos */ NULL, /* no sub protos */ 1, /* has constants */ - ( &(const bvalue[ 1]) { /* constants */ + ( &(const bvalue[ 2]) { /* constants */ /* K0 */ be_nested_str_literal("call_native"), + /* K1 */ be_const_int(3), }), - (be_nested_const_str("is_dirty", 418034110, 8)), + (be_nested_const_str("can_show", 960091187, 8)), ((bstring*) &be_const_str_input), ( &(const binstruction[ 4]) { /* code */ 0x8C040100, // 0000 GETMET R1 R0 K0 - 0x540E0003, // 0001 LDINT R3 4 + 0x580C0001, // 0001 LDCONST R3 K1 0x7C040400, // 0002 CALL R1 2 0x80040200, // 0003 RET 1 R1 }) @@ -538,6 +1135,69 @@ be_local_closure(Leds_is_dirty, /* name */ /*******************************************************************/ +/******************************************************************** +** Solidified function: clear +********************************************************************/ +be_local_closure(Leds_clear, /* name */ + be_nested_proto( + 4, /* nstack */ + 1, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 3]) { /* constants */ + /* K0 */ be_nested_str_literal("clear_to"), + /* K1 */ be_const_int(0), + /* K2 */ be_nested_str_literal("show"), + }), + (be_nested_const_str("clear", 1550717474, 5)), + ((bstring*) &be_const_str_input), + ( &(const binstruction[ 6]) { /* code */ + 0x8C040100, // 0000 GETMET R1 R0 K0 + 0x580C0001, // 0001 LDCONST R3 K1 + 0x7C040400, // 0002 CALL R1 2 + 0x8C040102, // 0003 GETMET R1 R0 K2 + 0x7C040200, // 0004 CALL R1 1 + 0x80000000, // 0005 RET 0 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: show +********************************************************************/ +be_local_closure(Leds_show, /* name */ + be_nested_proto( + 4, /* nstack */ + 1, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 2]) { /* constants */ + /* K0 */ be_nested_str_literal("call_native"), + /* K1 */ be_const_int(2), + }), + (be_nested_const_str("show", -1454906820, 4)), + ((bstring*) &be_const_str_input), + ( &(const binstruction[ 4]) { /* code */ + 0x8C040100, // 0000 GETMET R1 R0 K0 + 0x580C0001, // 0001 LDCONST R3 K1 + 0x7C040400, // 0002 CALL R1 2 + 0x80000000, // 0003 RET 0 + }) + ) +); +/*******************************************************************/ + + /******************************************************************** ** Solidified function: ctor ********************************************************************/ @@ -580,31 +1240,567 @@ be_local_closure(Leds_ctor, /* name */ /*******************************************************************/ +/******************************************************************** +** Solidified function: dirty +********************************************************************/ +be_local_closure(Leds_dirty, /* name */ + be_nested_proto( + 4, /* nstack */ + 1, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 1]) { /* constants */ + /* K0 */ be_nested_str_literal("call_native"), + }), + (be_nested_const_str("dirty", -1627386213, 5)), + ((bstring*) &be_const_str_input), + ( &(const binstruction[ 4]) { /* code */ + 0x8C040100, // 0000 GETMET R1 R0 K0 + 0x540E0004, // 0001 LDINT R3 5 + 0x7C040400, // 0002 CALL R1 2 + 0x80000000, // 0003 RET 0 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: get_pixel_color +********************************************************************/ +be_local_closure(Leds_segment_get_pixel_color, /* name */ + be_nested_proto( + 5, /* nstack */ + 2, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 3]) { /* constants */ + /* K0 */ be_nested_str_literal("strip"), + /* K1 */ be_nested_str_literal("get_pixel_color"), + /* K2 */ be_nested_str_literal("offseta"), + }), + (be_nested_const_str("get_pixel_color", 337490048, 15)), + ((bstring*) &be_const_str_input), + ( &(const binstruction[ 6]) { /* code */ + 0x88080100, // 0000 GETMBR R2 R0 K0 + 0x8C080501, // 0001 GETMET R2 R2 K1 + 0x88100102, // 0002 GETMBR R4 R0 K2 + 0x00100204, // 0003 ADD R4 R1 R4 + 0x7C080400, // 0004 CALL R2 2 + 0x80040400, // 0005 RET 1 R2 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: clear_to +********************************************************************/ +be_local_closure(Leds_segment_clear_to, /* name */ + be_nested_proto( + 9, /* nstack */ + 3, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 6]) { /* constants */ + /* K0 */ be_const_int(0), + /* K1 */ be_nested_str_literal("leds"), + /* K2 */ be_nested_str_literal("strip"), + /* K3 */ be_nested_str_literal("set_pixel_color"), + /* K4 */ be_nested_str_literal("offset"), + /* K5 */ be_const_int(1), + }), + (be_nested_const_str("clear_to", -766965166, 8)), + ((bstring*) &be_const_str_input), + ( &(const binstruction[14]) { /* code */ + 0x580C0000, // 0000 LDCONST R3 K0 + 0x88100101, // 0001 GETMBR R4 R0 K1 + 0x14100604, // 0002 LT R4 R3 R4 + 0x78120008, // 0003 JMPF R4 #000D + 0x88100102, // 0004 GETMBR R4 R0 K2 + 0x8C100903, // 0005 GETMET R4 R4 K3 + 0x88180104, // 0006 GETMBR R6 R0 K4 + 0x00180606, // 0007 ADD R6 R3 R6 + 0x5C1C0200, // 0008 MOVE R7 R1 + 0x5C200400, // 0009 MOVE R8 R2 + 0x7C100800, // 000A CALL R4 4 + 0x000C0705, // 000B ADD R3 R3 K5 + 0x7001FFF3, // 000C JMP #0001 + 0x80000000, // 000D RET 0 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: can_show +********************************************************************/ +be_local_closure(Leds_segment_can_show, /* name */ + be_nested_proto( + 3, /* nstack */ + 1, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 2]) { /* constants */ + /* K0 */ be_nested_str_literal("strip"), + /* K1 */ be_nested_str_literal("can_show"), + }), + (be_nested_const_str("can_show", 960091187, 8)), + ((bstring*) &be_const_str_input), + ( &(const binstruction[ 4]) { /* code */ + 0x88040100, // 0000 GETMBR R1 R0 K0 + 0x8C040301, // 0001 GETMET R1 R1 K1 + 0x7C040200, // 0002 CALL R1 1 + 0x80040200, // 0003 RET 1 R1 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: set_pixel_color +********************************************************************/ +be_local_closure(Leds_segment_set_pixel_color, /* name */ + be_nested_proto( + 9, /* nstack */ + 4, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 3]) { /* constants */ + /* K0 */ be_nested_str_literal("strip"), + /* K1 */ be_nested_str_literal("set_pixel_color"), + /* K2 */ be_nested_str_literal("offset"), + }), + (be_nested_const_str("set_pixel_color", 1275248356, 15)), + ((bstring*) &be_const_str_input), + ( &(const binstruction[ 8]) { /* code */ + 0x88100100, // 0000 GETMBR R4 R0 K0 + 0x8C100901, // 0001 GETMET R4 R4 K1 + 0x88180102, // 0002 GETMBR R6 R0 K2 + 0x00180206, // 0003 ADD R6 R1 R6 + 0x5C1C0400, // 0004 MOVE R7 R2 + 0x5C200600, // 0005 MOVE R8 R3 + 0x7C100800, // 0006 CALL R4 4 + 0x80000000, // 0007 RET 0 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: clear +********************************************************************/ +be_local_closure(Leds_segment_clear, /* name */ + be_nested_proto( + 4, /* nstack */ + 1, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 3]) { /* constants */ + /* K0 */ be_nested_str_literal("clear_to"), + /* K1 */ be_const_int(0), + /* K2 */ be_nested_str_literal("show"), + }), + (be_nested_const_str("clear", 1550717474, 5)), + ((bstring*) &be_const_str_input), + ( &(const binstruction[ 6]) { /* code */ + 0x8C040100, // 0000 GETMET R1 R0 K0 + 0x580C0001, // 0001 LDCONST R3 K1 + 0x7C040400, // 0002 CALL R1 2 + 0x8C040102, // 0003 GETMET R1 R0 K2 + 0x7C040200, // 0004 CALL R1 1 + 0x80000000, // 0005 RET 0 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: begin +********************************************************************/ +be_local_closure(Leds_segment_begin, /* name */ + be_nested_proto( + 1, /* nstack */ + 1, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 0, /* has constants */ + NULL, /* no const */ + (be_nested_const_str("begin", 1748273790, 5)), + ((bstring*) &be_const_str_input), + ( &(const binstruction[ 1]) { /* code */ + 0x80000000, // 0000 RET 0 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: pixel_count +********************************************************************/ +be_local_closure(Leds_segment_pixel_count, /* name */ + be_nested_proto( + 2, /* nstack */ + 1, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 1]) { /* constants */ + /* K0 */ be_nested_str_literal("leds"), + }), + (be_nested_const_str("pixel_count", -1855836553, 11)), + ((bstring*) &be_const_str_input), + ( &(const binstruction[ 2]) { /* code */ + 0x88040100, // 0000 GETMBR R1 R0 K0 + 0x80040200, // 0001 RET 1 R1 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: init +********************************************************************/ +be_local_closure(Leds_segment_init, /* name */ + be_nested_proto( + 6, /* nstack */ + 4, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 3]) { /* constants */ + /* K0 */ be_nested_str_literal("strip"), + /* K1 */ be_nested_str_literal("offset"), + /* K2 */ be_nested_str_literal("leds"), + }), + (be_nested_const_str("init", 380752755, 4)), + ((bstring*) &be_const_str_input), + ( &(const binstruction[10]) { /* code */ + 0x90020001, // 0000 SETMBR R0 K0 R1 + 0x60100009, // 0001 GETGBL R4 G9 + 0x5C140400, // 0002 MOVE R5 R2 + 0x7C100200, // 0003 CALL R4 1 + 0x90020204, // 0004 SETMBR R0 K1 R4 + 0x60100009, // 0005 GETGBL R4 G9 + 0x5C140600, // 0006 MOVE R5 R3 + 0x7C100200, // 0007 CALL R4 1 + 0x90020404, // 0008 SETMBR R0 K2 R4 + 0x80000000, // 0009 RET 0 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: pixel_size +********************************************************************/ +be_local_closure(Leds_segment_pixel_size, /* name */ + be_nested_proto( + 3, /* nstack */ + 1, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 2]) { /* constants */ + /* K0 */ be_nested_str_literal("strip"), + /* K1 */ be_nested_str_literal("pixel_size"), + }), + (be_nested_const_str("pixel_size", -2085831511, 10)), + ((bstring*) &be_const_str_input), + ( &(const binstruction[ 4]) { /* code */ + 0x88040100, // 0000 GETMBR R1 R0 K0 + 0x8C040301, // 0001 GETMET R1 R1 K1 + 0x7C040200, // 0002 CALL R1 1 + 0x80040200, // 0003 RET 1 R1 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: dirty +********************************************************************/ +be_local_closure(Leds_segment_dirty, /* name */ + be_nested_proto( + 3, /* nstack */ + 1, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 2]) { /* constants */ + /* K0 */ be_nested_str_literal("strip"), + /* K1 */ be_nested_str_literal("dirty"), + }), + (be_nested_const_str("dirty", -1627386213, 5)), + ((bstring*) &be_const_str_input), + ( &(const binstruction[ 4]) { /* code */ + 0x88040100, // 0000 GETMBR R1 R0 K0 + 0x8C040301, // 0001 GETMET R1 R1 K1 + 0x7C040200, // 0002 CALL R1 1 + 0x80000000, // 0003 RET 0 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: show +********************************************************************/ +be_local_closure(Leds_segment_show, /* name */ + be_nested_proto( + 4, /* nstack */ + 2, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 5]) { /* constants */ + /* K0 */ be_nested_str_literal("offset"), + /* K1 */ be_const_int(0), + /* K2 */ be_nested_str_literal("leds"), + /* K3 */ be_nested_str_literal("strip"), + /* K4 */ be_nested_str_literal("show"), + }), + (be_nested_const_str("show", -1454906820, 4)), + ((bstring*) &be_const_str_input), + ( &(const binstruction[16]) { /* code */ + 0x60080017, // 0000 GETGBL R2 G23 + 0x5C0C0200, // 0001 MOVE R3 R1 + 0x7C080200, // 0002 CALL R2 1 + 0x740A0007, // 0003 JMPT R2 #000C + 0x88080100, // 0004 GETMBR R2 R0 K0 + 0x1C080501, // 0005 EQ R2 R2 K1 + 0x780A0007, // 0006 JMPF R2 #000F + 0x88080102, // 0007 GETMBR R2 R0 K2 + 0x880C0103, // 0008 GETMBR R3 R0 K3 + 0x880C0702, // 0009 GETMBR R3 R3 K2 + 0x1C080403, // 000A EQ R2 R2 R3 + 0x780A0002, // 000B JMPF R2 #000F + 0x88080103, // 000C GETMBR R2 R0 K3 + 0x8C080504, // 000D GETMET R2 R2 K4 + 0x7C080200, // 000E CALL R2 1 + 0x80000000, // 000F RET 0 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: is_dirty +********************************************************************/ +be_local_closure(Leds_segment_is_dirty, /* name */ + be_nested_proto( + 3, /* nstack */ + 1, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 2]) { /* constants */ + /* K0 */ be_nested_str_literal("strip"), + /* K1 */ be_nested_str_literal("is_dirty"), + }), + (be_nested_const_str("is_dirty", 418034110, 8)), + ((bstring*) &be_const_str_input), + ( &(const binstruction[ 4]) { /* code */ + 0x88040100, // 0000 GETMBR R1 R0 K0 + 0x8C040301, // 0001 GETMET R1 R1 K1 + 0x7C040200, // 0002 CALL R1 1 + 0x80040200, // 0003 RET 1 R1 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: pixels_buffer +********************************************************************/ +be_local_closure(Leds_segment_pixels_buffer, /* name */ + be_nested_proto( + 2, /* nstack */ + 1, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 0, /* has constants */ + NULL, /* no const */ + (be_nested_const_str("pixels_buffer", 1229555807, 13)), + ((bstring*) &be_const_str_input), + ( &(const binstruction[ 2]) { /* code */ + 0x4C040000, // 0000 LDNIL R1 + 0x80040200, // 0001 RET 1 R1 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified class: Leds_segment +********************************************************************/ +be_local_class(Leds_segment, + 3, + NULL, + be_nested_map(16, + ( (struct bmapnode*) &(const bmapnode[]) { + { be_nested_key("get_pixel_color", 337490048, 15, -1), be_const_closure(Leds_segment_get_pixel_color_closure) }, + { be_nested_key("strip", -48555823, 5, -1), be_const_var(0) }, + { be_nested_key("clear_to", -766965166, 8, 5), be_const_closure(Leds_segment_clear_to_closure) }, + { be_nested_key("can_show", 960091187, 8, 13), be_const_closure(Leds_segment_can_show_closure) }, + { be_nested_key("set_pixel_color", 1275248356, 15, -1), be_const_closure(Leds_segment_set_pixel_color_closure) }, + { be_nested_key("clear", 1550717474, 5, -1), be_const_closure(Leds_segment_clear_closure) }, + { be_nested_key("is_dirty", 418034110, 8, -1), be_const_closure(Leds_segment_is_dirty_closure) }, + { be_nested_key("pixel_count", -1855836553, 11, -1), be_const_closure(Leds_segment_pixel_count_closure) }, + { be_nested_key("leds", 558858555, 4, -1), be_const_var(2) }, + { be_nested_key("pixel_size", -2085831511, 10, -1), be_const_closure(Leds_segment_pixel_size_closure) }, + { be_nested_key("offset", 348705738, 6, -1), be_const_var(1) }, + { be_nested_key("dirty", -1627386213, 5, 8), be_const_closure(Leds_segment_dirty_closure) }, + { be_nested_key("show", -1454906820, 4, -1), be_const_closure(Leds_segment_show_closure) }, + { be_nested_key("init", 380752755, 4, -1), be_const_closure(Leds_segment_init_closure) }, + { be_nested_key("begin", 1748273790, 5, 6), be_const_closure(Leds_segment_begin_closure) }, + { be_nested_key("pixels_buffer", 1229555807, 13, -1), be_const_closure(Leds_segment_pixels_buffer_closure) }, + })), + be_str_literal("Leds_segment") +); + +/******************************************************************** +** Solidified function: create_segment +********************************************************************/ +be_local_closure(Leds_create_segment, /* name */ + be_nested_proto( + 8, /* nstack */ + 3, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 5]) { /* constants */ + /* K0 */ be_nested_str_literal("leds"), + /* K1 */ be_const_int(0), + /* K2 */ be_nested_str_literal("value_error"), + /* K3 */ be_nested_str_literal("out of range"), + /* K4 */ be_const_class(be_class_Leds_segment), + }), + (be_nested_const_str("create_segment", -431444577, 14)), + ((bstring*) &be_const_str_input), + ( &(const binstruction[23]) { /* code */ + 0x600C0009, // 0000 GETGBL R3 G9 + 0x5C100200, // 0001 MOVE R4 R1 + 0x7C0C0200, // 0002 CALL R3 1 + 0x60100009, // 0003 GETGBL R4 G9 + 0x5C140400, // 0004 MOVE R5 R2 + 0x7C100200, // 0005 CALL R4 1 + 0x000C0604, // 0006 ADD R3 R3 R4 + 0x88100100, // 0007 GETMBR R4 R0 K0 + 0x240C0604, // 0008 GT R3 R3 R4 + 0x740E0003, // 0009 JMPT R3 #000E + 0x140C0301, // 000A LT R3 R1 K1 + 0x740E0001, // 000B JMPT R3 #000E + 0x140C0501, // 000C LT R3 R2 K1 + 0x780E0000, // 000D JMPF R3 #000F + 0xB0060503, // 000E RAISE 1 K2 K3 + 0x580C0004, // 000F LDCONST R3 K4 + 0xB4000004, // 0010 CLASS K4 + 0x5C100600, // 0011 MOVE R4 R3 + 0x5C140000, // 0012 MOVE R5 R0 + 0x5C180200, // 0013 MOVE R6 R1 + 0x5C1C0400, // 0014 MOVE R7 R2 + 0x7C100600, // 0015 CALL R4 3 + 0x80040800, // 0016 RET 1 R4 + }) + ) +); +/*******************************************************************/ + + /******************************************************************** ** Solidified class: Leds ********************************************************************/ extern const bclass be_class_Leds_ntv; be_local_class(Leds, - 1, + 2, &be_class_Leds_ntv, - be_nested_map(16, + be_nested_map(20, ( (struct bmapnode*) &(const bmapnode[]) { - { be_nested_key("get_pixel_color", 337490048, 15, -1), be_const_closure(Leds_get_pixel_color_closure) }, - { be_nested_key("ctor", 375399343, 4, -1), be_const_closure(Leds_ctor_closure) }, - { be_nested_key("clear", 1550717474, 5, 8), be_const_closure(Leds_clear_closure) }, - { be_nested_key("init", 380752755, 4, 13), be_const_closure(Leds_init_closure) }, - { be_nested_key("set_pixel_color", 1275248356, 15, -1), be_const_closure(Leds_set_pixel_color_closure) }, - { be_nested_key("is_dirty", 418034110, 8, -1), be_const_closure(Leds_is_dirty_closure) }, - { be_nested_key("to_gamma", 1597139862, 8, -1), be_const_closure(Leds_to_gamma_closure) }, { be_nested_key("pixel_count", -1855836553, 11, -1), be_const_closure(Leds_pixel_count_closure) }, - { be_nested_key("clear_to", -766965166, 8, -1), be_const_closure(Leds_clear_to_closure) }, + { be_nested_key("dirty", -1627386213, 5, 6), be_const_closure(Leds_dirty_closure) }, + { be_nested_key("to_gamma", 1597139862, 8, -1), be_const_closure(Leds_to_gamma_closure) }, + { be_nested_key("create_matrix", -766781373, 13, 1), be_const_closure(Leds_create_matrix_closure) }, + { be_nested_key("matrix", 365099244, 6, -1), be_const_static_closure(Leds_matrix_closure) }, { be_nested_key("pixel_size", -2085831511, 10, -1), be_const_closure(Leds_pixel_size_closure) }, - { be_nested_key("gamma", -802614262, 5, -1), be_const_var(0) }, - { be_nested_key("dirty", -1627386213, 5, -1), be_const_closure(Leds_dirty_closure) }, + { be_nested_key("ctor", 375399343, 4, 0), be_const_closure(Leds_ctor_closure) }, + { be_nested_key("pixels_buffer", 1229555807, 13, 13), be_const_closure(Leds_pixels_buffer_closure) }, + { be_nested_key("get_pixel_color", 337490048, 15, -1), be_const_closure(Leds_get_pixel_color_closure) }, { be_nested_key("show", -1454906820, 4, -1), be_const_closure(Leds_show_closure) }, + { be_nested_key("begin", 1748273790, 5, 17), be_const_closure(Leds_begin_closure) }, + { be_nested_key("leds", 558858555, 4, -1), be_const_var(1) }, + { be_nested_key("clear", 1550717474, 5, -1), be_const_closure(Leds_clear_closure) }, { be_nested_key("can_show", 960091187, 8, -1), be_const_closure(Leds_can_show_closure) }, - { be_nested_key("begin", 1748273790, 5, 5), be_const_closure(Leds_begin_closure) }, - { be_nested_key("pixels_buffer", 1229555807, 13, 1), be_const_closure(Leds_pixels_buffer_closure) }, + { be_nested_key("gamma", -802614262, 5, 12), be_const_var(0) }, + { be_nested_key("init", 380752755, 4, 11), be_const_closure(Leds_init_closure) }, + { be_nested_key("set_pixel_color", 1275248356, 15, 9), be_const_closure(Leds_set_pixel_color_closure) }, + { be_nested_key("clear_to", -766965166, 8, 18), be_const_closure(Leds_clear_to_closure) }, + { be_nested_key("is_dirty", 418034110, 8, -1), be_const_closure(Leds_is_dirty_closure) }, + { be_nested_key("create_segment", -431444577, 14, -1), be_const_closure(Leds_create_segment_closure) }, })), be_str_literal("Leds") ); diff --git a/lib/libesp32/Berry/default/be_leds_matrix_lib.c b/lib/libesp32/Berry/default/be_leds_matrix_lib.c deleted file mode 100644 index 1aafb3db4..000000000 --- a/lib/libesp32/Berry/default/be_leds_matrix_lib.c +++ /dev/null @@ -1,185 +0,0 @@ -/******************************************************************** - * Berry class `Leds_matrix` - * - *******************************************************************/ -#include "be_constobj.h" - -#ifdef USE_WS2812 - -/******************************************************************** -** Solidified function: get_alternate -********************************************************************/ -be_local_closure(Leds_matrix_get_alternate, /* name */ - be_nested_proto( - 2, /* nstack */ - 1, /* argc */ - 0, /* varg */ - 0, /* has upvals */ - NULL, /* no upvals */ - 0, /* has sup protos */ - NULL, /* no sub protos */ - 1, /* has constants */ - ( &(const bvalue[ 1]) { /* constants */ - /* K0 */ be_nested_str_literal("alternate"), - }), - (be_nested_const_str("get_alternate", 1450148894, 13)), - ((bstring*) &be_const_str_input), - ( &(const binstruction[ 2]) { /* code */ - 0x88040100, // 0000 GETMBR R1 R0 K0 - 0x80040200, // 0001 RET 1 R1 - }) - ) -); -/*******************************************************************/ - - -/******************************************************************** -** Solidified function: set_alternate -********************************************************************/ -be_local_closure(Leds_matrix_set_alternate, /* name */ - be_nested_proto( - 2, /* nstack */ - 2, /* argc */ - 0, /* varg */ - 0, /* has upvals */ - NULL, /* no upvals */ - 0, /* has sup protos */ - NULL, /* no sub protos */ - 1, /* has constants */ - ( &(const bvalue[ 1]) { /* constants */ - /* K0 */ be_nested_str_literal("alternate"), - }), - (be_nested_const_str("set_alternate", 1709680562, 13)), - ((bstring*) &be_const_str_input), - ( &(const binstruction[ 2]) { /* code */ - 0x90020001, // 0000 SETMBR R0 K0 R1 - 0x80000000, // 0001 RET 0 - }) - ) -); -/*******************************************************************/ - - -/******************************************************************** -** Solidified function: set_matrix_pixel_color -********************************************************************/ -be_local_closure(Leds_matrix_set_matrix_pixel_color, /* name */ - be_nested_proto( - 10, /* nstack */ - 5, /* argc */ - 0, /* varg */ - 0, /* has upvals */ - NULL, /* no upvals */ - 0, /* has sup protos */ - NULL, /* no sub protos */ - 1, /* has constants */ - ( &(const bvalue[ 6]) { /* constants */ - /* K0 */ be_nested_str_literal("alternate"), - /* K1 */ be_const_int(2), - /* K2 */ be_nested_str_literal("set_pixel_color"), - /* K3 */ be_nested_str_literal("w"), - /* K4 */ be_nested_str_literal("h"), - /* K5 */ be_const_int(1), - }), - (be_nested_const_str("set_matrix_pixel_color", 1197149462, 22)), - ((bstring*) &be_const_str_input), - ( &(const binstruction[23]) { /* code */ - 0x88140100, // 0000 GETMBR R5 R0 K0 - 0x7816000C, // 0001 JMPF R5 #000F - 0x10140301, // 0002 MOD R5 R1 K1 - 0x7816000A, // 0003 JMPF R5 #000F - 0x8C140102, // 0004 GETMET R5 R0 K2 - 0x881C0103, // 0005 GETMBR R7 R0 K3 - 0x081C0207, // 0006 MUL R7 R1 R7 - 0x88200104, // 0007 GETMBR R8 R0 K4 - 0x001C0E08, // 0008 ADD R7 R7 R8 - 0x041C0E02, // 0009 SUB R7 R7 R2 - 0x041C0F05, // 000A SUB R7 R7 K5 - 0x5C200600, // 000B MOVE R8 R3 - 0x5C240800, // 000C MOVE R9 R4 - 0x7C140800, // 000D CALL R5 4 - 0x70020006, // 000E JMP #0016 - 0x8C140102, // 000F GETMET R5 R0 K2 - 0x881C0103, // 0010 GETMBR R7 R0 K3 - 0x081C0207, // 0011 MUL R7 R1 R7 - 0x001C0E02, // 0012 ADD R7 R7 R2 - 0x5C200600, // 0013 MOVE R8 R3 - 0x5C240800, // 0014 MOVE R9 R4 - 0x7C140800, // 0015 CALL R5 4 - 0x80000000, // 0016 RET 0 - }) - ) -); -/*******************************************************************/ - - -/******************************************************************** -** Solidified function: init -********************************************************************/ -be_local_closure(Leds_matrix_init, /* name */ - be_nested_proto( - 10, /* nstack */ - 5, /* argc */ - 0, /* varg */ - 0, /* has upvals */ - NULL, /* no upvals */ - 0, /* has sup protos */ - NULL, /* no sub protos */ - 1, /* has constants */ - ( &(const bvalue[ 4]) { /* constants */ - /* K0 */ be_nested_str_literal("w"), - /* K1 */ be_nested_str_literal("h"), - /* K2 */ be_nested_str_literal("alternate"), - /* K3 */ be_nested_str_literal("init"), - }), - (be_nested_const_str("init", 380752755, 4)), - ((bstring*) &be_const_str_input), - ( &(const binstruction[13]) { /* code */ - 0x90020001, // 0000 SETMBR R0 K0 R1 - 0x90020202, // 0001 SETMBR R0 K1 R2 - 0x50140000, // 0002 LDBOOL R5 0 0 - 0x90020405, // 0003 SETMBR R0 K2 R5 - 0x60140003, // 0004 GETGBL R5 G3 - 0x5C180000, // 0005 MOVE R6 R0 - 0x7C140200, // 0006 CALL R5 1 - 0x8C140B03, // 0007 GETMET R5 R5 K3 - 0x081C0202, // 0008 MUL R7 R1 R2 - 0x5C200600, // 0009 MOVE R8 R3 - 0x5C240800, // 000A MOVE R9 R4 - 0x7C140800, // 000B CALL R5 4 - 0x80000000, // 000C RET 0 - }) - ) -); -/*******************************************************************/ - - -/******************************************************************** -** Solidified class: Leds_matrix -********************************************************************/ -extern const bclass be_class_Leds; -be_local_class(Leds_matrix, - 3, - &be_class_Leds, - be_nested_map(7, - ( (struct bmapnode*) &(const bmapnode[]) { - { be_nested_key("init", 380752755, 4, 3), be_const_closure(Leds_matrix_init_closure) }, - { be_nested_key("h", -317966505, 1, -1), be_const_var(0) }, - { be_nested_key("set_alternate", 1709680562, 13, 6), be_const_closure(Leds_matrix_set_alternate_closure) }, - { be_nested_key("set_matrix_pixel_color", 1197149462, 22, 4), be_const_closure(Leds_matrix_set_matrix_pixel_color_closure) }, - { be_nested_key("w", -234078410, 1, -1), be_const_var(1) }, - { be_nested_key("get_alternate", 1450148894, 13, 0), be_const_closure(Leds_matrix_get_alternate_closure) }, - { be_nested_key("alternate", 1140253277, 9, -1), be_const_var(2) }, - })), - be_str_literal("Leds_matrix") -); -/*******************************************************************/ - -void be_load_Leds_matrix_class(bvm *vm) { - be_pushntvclass(vm, &be_class_Leds_matrix); - be_setglobal(vm, "Leds_matrix"); - be_pop(vm, 1); -} - - -#endif // USE_WS2812 diff --git a/lib/libesp32/Berry/default/be_leds_ntv_lib.c b/lib/libesp32/Berry/default/be_leds_ntv_lib.c index 5affc1c71..357786978 100644 --- a/lib/libesp32/Berry/default/be_leds_ntv_lib.c +++ b/lib/libesp32/Berry/default/be_leds_ntv_lib.c @@ -8,9 +8,7 @@ class Leds_ntv var _p # pointer to internal object of type `NeoPixelBus(uint16_t countPixels, uint8_t pin)` var _t # type of led strip static WS2812_GRB = 1 - static WS2812_GRBW = 2 - static SK6812_GRB = 3 - static SK6812_GRBW = 4 + static SK6812_GRBW = 2 # skeleton for native call def call_native() end @@ -30,15 +28,13 @@ extern int be_neopixelbus_call_native(bvm *vm); be_local_class(Leds_ntv, 2, NULL, - be_nested_map(7, + be_nested_map(5, ( (struct bmapnode*) &(const bmapnode[]) { - { be_nested_key("WS2812_GRB", 1736405692, 10, 5), be_const_int(1) }, - { be_nested_key("_p", 1594591802, 2, -1), be_const_var(0) }, - { be_nested_key("WS2812_GRBW", -660477967, 11, 3), be_const_int(2) }, { be_nested_key("call_native", 1389147405, 11, -1), be_const_func(be_neopixelbus_call_native) }, - { be_nested_key("SK6812_GRBW", 81157857, 11, -1), be_const_int(4) }, { be_nested_key("_t", 1527481326, 2, -1), be_const_var(1) }, - { be_nested_key("SK6812_GRB", 1159411308, 10, 1), be_const_int(3) }, + { be_nested_key("_p", 1594591802, 2, 3), be_const_var(0) }, + { be_nested_key("SK6812_GRBW", 81157857, 11, 4), be_const_int(2) }, + { be_nested_key("WS2812_GRB", 1736405692, 10, -1), be_const_int(1) }, })), be_str_literal("Leds_ntv") ); diff --git a/lib/libesp32/Berry/default/be_modtab.c b/lib/libesp32/Berry/default/be_modtab.c index 5f04457ac..0c54ce990 100644 --- a/lib/libesp32/Berry/default/be_modtab.c +++ b/lib/libesp32/Berry/default/be_modtab.c @@ -138,7 +138,6 @@ extern void be_load_webclient_lib(bvm *vm); extern void be_load_crypto_lib(bvm *vm); extern void be_load_Leds_ntv_class(bvm *vm); extern void be_load_Leds_class(bvm *vm); -extern void be_load_Leds_matrix_class(bvm *vm); extern void be_load_Leds_animator_class(bvm *vm); extern void be_load_ctypes_lib(bvm *vm); @@ -197,7 +196,6 @@ BERRY_API void be_load_custom_libs(bvm *vm) #ifdef USE_WS2812 be_load_Leds_ntv_class(vm); be_load_Leds_class(vm); - be_load_Leds_matrix_class(vm); be_load_Leds_animator_class(vm); #endif // USE_WS2812 #ifdef USE_I2S_AUDIO_BERRY diff --git a/lib/libesp32/Berry/default/embedded/leds.be b/lib/libesp32/Berry/default/embedded/leds.be index 289ad1118..11a0489af 100644 --- a/lib/libesp32/Berry/default/embedded/leds.be +++ b/lib/libesp32/Berry/default/embedded/leds.be @@ -24,12 +24,14 @@ class Leds : Leds_ntv var gamma # if true, apply gamma (true is default) + var leds # number of leds # leds:int = number of leds of the strip # gpio:int (optional) = GPIO for NeoPixel. If not specified, takes the WS2812 gpio # type:int (optional) = Type of LED, defaults to WS2812 RGB # rmt:int (optional) = RMT hardware channel to use, leave default unless you have a good reason def init(leds, gpio, type, rmt) # rmt is optional self.gamma = true # gamma is enabled by default, it should be disabled explicitly if needed + self.leds = int(leds) if gpio == nil && gpio.pin(gpio.WS2812) >= 0 gpio = gpio.pin(gpio.WS2812) @@ -41,7 +43,7 @@ class Leds : Leds_ntv end # initialize the structure - self.ctor(leds, gpio, type, rmt) + self.ctor(self.leds, gpio, type, rmt) if self._p == nil raise "internal_error", "couldn't not initialize noepixelbus" end @@ -124,8 +126,176 @@ class Leds : Leds_ntv b end end + + # `segment` + # create a new `strip` object that maps a part of the current strip + def create_segment(offset, leds) + if int(offset) + int(leds) > self.leds || offset < 0 || leds < 0 + raise "value_error", "out of range" + end + + # inner class + class Leds_segment + var strip + var offset, leds + + def init(strip, offset, leds) + self.strip = strip + self.offset = int(offset) + self.leds = int(leds) + end + + def clear() + self.clear_to(0x000000) + self.show() + end + + def begin() + # do nothing, already being handled by physical strip + end + def show(force) + # don't trigger on segment, you will need to trigger on full strip instead + if bool(force) || (self.offset == 0 && self.leds == self.strip.leds) + self.strip.show() + end + end + def can_show() + return self.strip.can_show() + end + def is_dirty() + return self.strip.is_dirty() + end + def dirty() + self.strip.dirty() + end + def pixels_buffer() + return nil + end + def pixel_size() + return self.strip.pixel_size() + end + def pixel_count() + return self.leds + end + def clear_to(col, bri) + var i = 0 + while i < self.leds + self.strip.set_pixel_color(i + self.offset, col, bri) + i += 1 + end + end + def set_pixel_color(idx, col, bri) + self.strip.set_pixel_color(idx + self.offset, col, bri) + end + def get_pixel_color(idx) + return self.strip.get_pixel_color(idx + self.offseta) + end + end + + return Leds_segment(self, offset, leds) + + end + + def create_matrix(w, h, offset) + offset = int(offset) + w = int(w) + h = int(h) + if offset == nil offset = 0 end + if w * h + offset > self.leds || h < 0 || w < 0 || offset < 0 + raise "value_error", "out of range" + end + + # inner class + class Leds_matrix + var strip + var offset + var h, w + var alternate # are rows in alternate mode (even/odd are reversed) + + def init(strip, w, h, offset) + self.strip = strip + self.offset = offset + self.h = h + self.w = w + self.alternate = false + end + + def clear() + self.clear_to(0x000000) + self.show() + end + + def begin() + # do nothing, already being handled by physical strip + end + def show(force) + # don't trigger on segment, you will need to trigger on full strip instead + if bool(force) || (self.offset == 0 && self.w * self.h == self.strip.leds) + self.strip.show() + end + end + def can_show() + return self.strip.can_show() + end + def is_dirty() + return self.strip.is_dirty() + end + def dirty() + self.strip.dirty() + end + def pixels_buffer() + return nil + end + def pixel_size() + return self.strip.pixel_size() + end + def pixel_count() + return self.w * self.h + end + def clear_to(col, bri) + var i = 0 + while i < self.w * self.h + self.strip.set_pixel_color(i + self.offset, col, bri) + i += 1 + end + end + def set_pixel_color(idx, col, bri) + self.strip.set_pixel_color(idx + self.offset, col, bri) + end + def get_pixel_color(idx) + return self.strip.get_pixel_color(idx + self.offseta) + end + + # Leds_matrix specific + def set_alternate(alt) + self.alternate = alt + end + def get_alternate() + return self.alternate + end + + def set_matrix_pixel_color(x, y, col, bri) + if self.alternate && x % 2 + # reversed line + self.strip.set_pixel_color(x * self.w + self.h - y - 1 + self.offset, col, bri) + else + self.strip.set_pixel_color(x * self.w + y + self.offset, col, bri) + end + end + end + + return Leds_matrix(self, w, h, offset) + + end + + static def matrix(w, h, gpio, rmt) + var strip = Leds(w * h, gpio, rmt) + var matrix = strip.create_matrix(w, h, 0) + return matrix + end end + #- var s = Leds(25, gpio.pin(gpio.WS2812, 1)) @@ -144,34 +314,6 @@ anim() -# -class Leds_matrix : Leds - var h, w - var alternate # are rows in alternate mode (even/odd are reversed) - - def init(w, h, gpio, rmt) - self.w = w - self.h = h - self.alternate = false - super(self).init(w * h, gpio, rmt) - end - - def set_alternate(alt) - self.alternate = alt - end - def get_alternate() - return self.alternate - end - - def set_matrix_pixel_color(x, y, col, bri) - if self.alternate && x % 2 - # reversed line - self.set_pixel_color(x * self.w + self.h - y - 1, col, bri) - else - self.set_pixel_color(x * self.w + y, col, bri) - end - end -end - #- var s = Leds_matrix(5, 5, gpio.pin(gpio.WS2812, 1)) diff --git a/tasmota/berry/leds/rainbow.be b/tasmota/berry/leds/rainbow.be index bb7a4f105..bf3801556 100644 --- a/tasmota/berry/leds/rainbow.be +++ b/tasmota/berry/leds/rainbow.be @@ -11,28 +11,6 @@ rainbow.start() import animate -# https://stackoverflow.com/questions/34187171/fast-integer-square-root-approximation -def fast_sqrt_int(val) - var a, b - - if val < 2 return val end - - a = 1255 # starting point is relatively unimportant - - b = val / a; a = (a+b) /2; - b = val / a; a = (a+b) /2; - b = val / a; a = (a+b) /2; - b = val / a; a = (a+b) /2; - b = val / a; a = (a+b) /2; - b = val / a; a = (a+b) /2; - if (val < 20000) - b = val / a; a = (a+b) /2; - b = val / a; a = (a+b) /2; - end - - return a -end - class Rainbow : Leds_animator var cur_offset # current offset in the palette static palette = [ 0xFF0000, #- red -# @@ -45,6 +23,7 @@ class Rainbow : Leds_animator ] def init(strip, duration) + import animate super(self).init(strip) self.cur_offset = 0 # add an animator to change `self.cur_offset` to each value of the palette @@ -73,7 +52,7 @@ end #- -var strip = Leds_matrix(5,5, gpio.pin(gpio.WS2812, 1)) +var strip = Leds.matrix(5,5, gpio.pin(gpio.WS2812, 1)) var r = Rainbow(strip, 1.0) r.start() @@ -91,6 +70,7 @@ class Rainbow_stripes : Leds_animator ] def init(strip, duration) + import animate super(self).init(strip) self.cur_offset = 0 # add an animator to change `self.cur_offset` to each value of the palette @@ -125,7 +105,7 @@ end #- -var strip = Leds_matrix(5,5, gpio.pin(gpio.WS2812, 1)) +var strip = Leds.matrix(5,5, gpio.pin(gpio.WS2812, 1)) var r = Rainbow_Matrix(strip, 0.5) r.start() @@ -138,6 +118,7 @@ class Round : Leds_animator var h def init(strip, glow_duration, color_duration) + import animate super(self).init(strip) self.cur_val = 5 << 8 self.h = 0 # start with hue = 0 (red) @@ -162,7 +143,7 @@ class Round : Leds_animator var x = 0 while x < w var col = col_ref - var dist = fast_sqrt_int( ((y - ch)*(y - ch) + (x - cw)*(x - cw)) << 16) + var dist = self.fast_sqrt_int( ((y - ch)*(y - ch) + (x - cw)*(x - cw)) << 16) var rel_bri = tasmota.scale_uint(dist, 0, self.cur_val, bri, 0) set_matrix_pixel_color(strip, x, y, col, rel_bri) # simulate the method call without GETMET x += 1 @@ -172,11 +153,32 @@ class Round : Leds_animator strip.show() end + # https://stackoverflow.com/questions/34187171/fast-integer-square-root-approximation + static def fast_sqrt_int(val) + var a, b + + if val < 2 return val end + + a = 1255 # starting point is relatively unimportant + + b = val / a; a = (a+b) /2; + b = val / a; a = (a+b) /2; + b = val / a; a = (a+b) /2; + b = val / a; a = (a+b) /2; + b = val / a; a = (a+b) /2; + b = val / a; a = (a+b) /2; + if (val < 20000) + b = val / a; a = (a+b) /2; + b = val / a; a = (a+b) /2; + end + + return a + end end #- -var strip = Leds_matrix(5,5, gpio.pin(gpio.WS2812, 1)) +var strip = Leds.matrix(5,5, gpio.pin(gpio.WS2812, 1)) var r = Round(strip, 2, 30) r.start() diff --git a/tasmota/xdrv_52_3_berry_leds.ino b/tasmota/xdrv_52_3_berry_leds.ino index 5e7d95b77..1801f1260 100644 --- a/tasmota/xdrv_52_3_berry_leds.ino +++ b/tasmota/xdrv_52_3_berry_leds.ino @@ -28,16 +28,12 @@ enum { ws2812_grb = 1, - ws2812_grbw = 2, - sk6812_grb = 3, - sk6812_grbw = 4, + sk6812_grbw = 2, neopixel_type_end }; typedef NeoPixelBus neopixel_ws2812_grb_t; -typedef NeoPixelBus neopixel_ws2812_grbw_t; -typedef NeoPixelBus neopixel_sk6812_grb_t; typedef NeoPixelBus neopixel_sk6812_grbw_t; @@ -124,10 +120,6 @@ extern "C" { switch (neopixel_type) { case ws2812_grb: strip = new neopixel_ws2812_grb_t(leds, gpio, (NeoBusChannel) rmt); break; - case ws2812_grbw: strip = new neopixel_ws2812_grbw_t(leds, gpio, (NeoBusChannel) rmt); - break; - case sk6812_grb: strip = new neopixel_sk6812_grb_t(leds, gpio, (NeoBusChannel) rmt); - break; case sk6812_grbw: strip = new neopixel_sk6812_grbw_t(leds, gpio, (NeoBusChannel) rmt); break; } @@ -141,8 +133,6 @@ extern "C" { const void * s = be_get_neopixelbus(vm); // raises an exception if pointer is invalid // initialize all possible variants neopixel_ws2812_grb_t * s_ws2812_grb = (leds_type == ws2812_grb) ? (neopixel_ws2812_grb_t*) s : nullptr; - neopixel_ws2812_grbw_t * s_ws2812_grbw = (leds_type == ws2812_grbw) ? (neopixel_ws2812_grbw_t*) s : nullptr; - neopixel_sk6812_grb_t * s_sk6812_grb = (leds_type == sk6812_grb) ? (neopixel_sk6812_grb_t*) s : nullptr; neopixel_sk6812_grbw_t * s_sk6812_grbw = (leds_type == sk6812_grbw) ? (neopixel_sk6812_grbw_t*) s : nullptr; be_pushnil(vm); // push a default `nil` return value @@ -150,46 +140,32 @@ extern "C" { switch (cmd) { case 1: // # 01 : begin void -> void if (s_ws2812_grb) s_ws2812_grb->Begin(); - if (s_ws2812_grbw) s_ws2812_grbw->Begin(); - if (s_sk6812_grb) s_sk6812_grb->Begin(); if (s_sk6812_grbw) s_sk6812_grbw->Begin(); break; case 2: // # 02 : show void -> void if (s_ws2812_grb) s_ws2812_grb->Show(); - if (s_ws2812_grbw) s_ws2812_grbw->Show(); - if (s_sk6812_grb) s_sk6812_grb->Show(); if (s_sk6812_grbw) s_sk6812_grbw->Show(); break; case 3: // # 03 : CanShow void -> bool if (s_ws2812_grb) be_pushbool(vm, s_ws2812_grb->CanShow()); - if (s_ws2812_grbw) be_pushbool(vm, s_ws2812_grbw->CanShow()); - if (s_sk6812_grb) be_pushbool(vm, s_sk6812_grb->CanShow()); if (s_sk6812_grbw) be_pushbool(vm, s_sk6812_grbw->CanShow()); break; case 4: // # 04 : IsDirty void -> bool if (s_ws2812_grb) be_pushbool(vm, s_ws2812_grb->IsDirty()); - if (s_ws2812_grbw) be_pushbool(vm, s_ws2812_grbw->IsDirty()); - if (s_sk6812_grb) be_pushbool(vm, s_sk6812_grb->IsDirty()); if (s_sk6812_grbw) be_pushbool(vm, s_sk6812_grbw->IsDirty()); break; case 5: // # 05 : Dirty void -> void if (s_ws2812_grb) s_ws2812_grb->Dirty(); - if (s_ws2812_grbw) s_ws2812_grbw->Dirty(); - if (s_sk6812_grb) s_sk6812_grb->Dirty(); if (s_sk6812_grbw) s_sk6812_grbw->Dirty(); break; case 6: // # 06 : Pixels void -> bytes() (mapped to the buffer) { size_t pixels_bytes; if (s_ws2812_grb) pixels_bytes = s_ws2812_grb->PixelsSize(); - if (s_ws2812_grbw) pixels_bytes = s_ws2812_grbw->PixelsSize(); - if (s_sk6812_grb) pixels_bytes = s_sk6812_grb->PixelsSize(); if (s_sk6812_grbw) pixels_bytes = s_sk6812_grbw->PixelsSize(); uint8_t * pixels; if (s_ws2812_grb) pixels = s_ws2812_grb->Pixels(); - if (s_ws2812_grbw) pixels = s_ws2812_grbw->Pixels(); - if (s_sk6812_grb) pixels = s_sk6812_grb->Pixels(); if (s_sk6812_grbw) pixels = s_sk6812_grbw->Pixels(); be_getbuiltin(vm, "bytes"); @@ -201,14 +177,10 @@ extern "C" { break; case 7: // # 07 : PixelSize void -> int if (s_ws2812_grb) be_pushint(vm, s_ws2812_grb->PixelSize()); - if (s_ws2812_grbw) be_pushint(vm, s_ws2812_grbw->PixelSize()); - if (s_sk6812_grb) be_pushint(vm, s_sk6812_grb->PixelSize()); if (s_sk6812_grbw) be_pushint(vm, s_sk6812_grbw->PixelSize()); break; case 8: // # 08 : PixelCount void -> int if (s_ws2812_grb) be_pushint(vm, s_ws2812_grb->PixelCount()); - if (s_ws2812_grbw) be_pushint(vm, s_ws2812_grbw->PixelCount()); - if (s_sk6812_grb) be_pushint(vm, s_sk6812_grb->PixelCount()); if (s_sk6812_grbw) be_pushint(vm, s_sk6812_grbw->PixelCount()); break; case 9: // # 09 : ClearTo (color:??) -> void @@ -219,8 +191,6 @@ extern "C" { uint8_t g = (rgbw & 0xFF00) >> 8; uint8_t b = (rgbw & 0xFF); if (s_ws2812_grb) s_ws2812_grb->ClearTo(RgbColor(r, g, b)); - if (s_ws2812_grbw) s_ws2812_grbw->ClearTo(RgbwColor(r, g, b, 0)); - if (s_sk6812_grb) s_sk6812_grb->ClearTo(RgbColor(r, g, b)); if (s_sk6812_grbw) s_sk6812_grbw->ClearTo(RgbwColor(r, g, b, 0)); } break; @@ -233,8 +203,6 @@ extern "C" { uint8_t g = (rgbw & 0xFF00) >> 8; uint8_t b = (rgbw & 0xFF); if (s_ws2812_grb) s_ws2812_grb->SetPixelColor(idx, RgbColor(r, g, b)); - if (s_ws2812_grbw) s_ws2812_grbw->SetPixelColor(idx, RgbwColor(r, g, b, 0)); - if (s_sk6812_grb) s_sk6812_grb->SetPixelColor(idx, RgbColor(r, g, b)); if (s_sk6812_grbw) s_sk6812_grbw->SetPixelColor(idx, RgbwColor(r, g, b, 0)); } break; @@ -247,43 +215,12 @@ extern "C" { RgbColor rgb = s_ws2812_grb->GetPixelColor(idx); be_pushint(vm, (rgb.R << 16) | (rgb.G << 8) | rgb.B); } - if (s_ws2812_grbw) { - RgbwColor rgbw = s_ws2812_grbw->GetPixelColor(idx); - be_pushint(vm, (rgbw.W << 24) | (rgb.R << 16) | (rgb.G << 8) | rgb.B); - } - if (s_sk6812_grb) { - RgbColor rgb = s_sk6812_grb->GetPixelColor(idx); - be_pushint(vm, (rgb.R << 16) | (rgb.G << 8) | rgb.B); - } if (s_sk6812_grbw) { RgbwColor rgbw = s_sk6812_grbw->GetPixelColor(idx); be_pushint(vm, (rgbw.W << 24) | (rgb.R << 16) | (rgb.G << 8) | rgb.B); } } break; - // case 20: // # 20 : RotateLeft (rot:int [, first:int, last:int]) -> void - // case 21: // # 21 : RotateRight (rot:int [, first:int, last:int]) -> void - // case 22: // # 22 : ShiftLeft (rot:int [, first:int, last:int]) -> void - // case 23: // # 23 : ShiftRight (rot:int [, first:int, last:int]) -> void - // { - // int32_t rot = be_toint(vm, 3); - // int32_t first = -1; - // int32_t last = -1; - // if (argc >= 5) { - // first = be_toint(vm, 4); - // last = be_toint(vm, 5); - // } - // if (20 == cmd) { - // if (first >= 0) { strip->RotateLeft(rot, first, last); } else { strip->RotateLeft(rot); }; - // } else if (21 == cmd) { - // if (first >= 0) { strip->RotateRight(rot, first, last); } else { strip->RotateRight(rot); }; - // } else if (22 == cmd) { - // if (first >= 0) { strip->ShiftLeft(rot, first, last); } else { strip->ShiftLeft(rot); }; - // } else if (23 == cmd) { - // if (first >= 0) { strip->ShiftRight(rot, first, last); } else { strip->ShiftRight(rot); }; - // } - // } - // break; default: break; }