@@ -43,24 +43,17 @@ MP_DEFINE_CONST_FUN_OBJ_VAR(ucomputer_push_signal_obj, 1, ucomputer_push_signal)
4343
4444STATIC mp_obj_t ucomputer_pop_signal (mp_obj_t ticks_obj ) {
4545 mp_int_t ticks = mp_obj_get_int (ticks_obj );
46- return wrap_result (__syscall1 (SYS_SIGNAL_REQUEST , (int ) ticks ));
46+ return wrap_result (__syscall1 (SYS_SIGNAL_POP , (int ) ticks ));
4747}
4848
4949MP_DEFINE_CONST_FUN_OBJ_1 (ucomputer_pop_signal_obj , ucomputer_pop_signal );
5050
5151
52- STATIC mp_obj_t ucomputer_get_cost_per_tick () {
53- return wrap_result (__syscall0 (SYS_COMPUTER_GET_COST_PER_TICK ));
54- }
55-
56- MP_DEFINE_CONST_FUN_OBJ_0 (ucomputer_get_cost_per_tick_obj , ucomputer_get_cost_per_tick );
57-
58-
59- STATIC mp_obj_t ucomputer_last_error () {
52+ STATIC mp_obj_t ucomputer_get_last_error () {
6053 return wrap_result (__syscall0 (SYS_COMPUTER_LAST_ERROR ));
6154}
6255
63- MP_DEFINE_CONST_FUN_OBJ_0 (ucomputer_last_error_obj , ucomputer_last_error );
56+ MP_DEFINE_CONST_FUN_OBJ_0 (ucomputer_get_last_error_obj , ucomputer_get_last_error );
6457
6558
6659STATIC mp_obj_t ucomputer_beep (size_t n_args , const mp_obj_t * args ) {
@@ -87,11 +80,11 @@ STATIC mp_obj_t ucomputer_beep(size_t n_args, const mp_obj_t *args) {
8780MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN (ucomputer_beep_obj , 1 , 2 , ucomputer_beep );
8881
8982
90- STATIC mp_obj_t ucomputer_users () {
83+ STATIC mp_obj_t ucomputer_get_users () {
9184 return wrap_result (__syscall0 (SYS_COMPUTER_USERS ));
9285}
9386
94- MP_DEFINE_CONST_FUN_OBJ_0 (ucomputer_users_obj , ucomputer_users );
87+ MP_DEFINE_CONST_FUN_OBJ_0 (ucomputer_get_users_obj , ucomputer_get_users );
9588
9689
9790STATIC mp_obj_t ucomputer_add_user (mp_obj_t user_obj ) {
@@ -128,6 +121,44 @@ STATIC mp_obj_t ucomputer_get_tmp_address() {
128121MP_DEFINE_CONST_FUN_OBJ_0 (ucomputer_get_tmp_address_obj , ucomputer_get_tmp_address );
129122
130123
124+ STATIC mp_obj_t ucomputer_get_energy () {
125+ return wrap_result (__syscall0 (SYS_COMPUTER_ENERGY ));
126+ }
127+
128+ MP_DEFINE_CONST_FUN_OBJ_0 (ucomputer_get_energy_obj , ucomputer_get_energy );
129+
130+
131+ STATIC mp_obj_t ucomputer_get_max_energy () {
132+ return wrap_result (__syscall0 (SYS_COMPUTER_MAX_ENERGY ));
133+ }
134+
135+ MP_DEFINE_CONST_FUN_OBJ_0 (ucomputer_get_max_energy_obj , ucomputer_get_max_energy );
136+
137+
138+ STATIC mp_obj_t ucomputer_get_architectures () {
139+ return wrap_result (__syscall0 (SYS_COMPUTER_GET_ARCHITECTURES ));
140+ }
141+
142+ MP_DEFINE_CONST_FUN_OBJ_0 (ucomputer_get_architectures_obj , ucomputer_get_architectures );
143+
144+
145+ STATIC mp_obj_t ucomputer_get_architecture () {
146+ return wrap_result (__syscall0 (SYS_COMPUTER_GET_ARCHITECTURE ));
147+ }
148+
149+ MP_DEFINE_CONST_FUN_OBJ_0 (ucomputer_get_architecture_obj , ucomputer_get_architecture );
150+
151+
152+ STATIC mp_obj_t ucomputer_set_architecture (mp_obj_t name_obj ) {
153+ size_t len = 0 ;
154+ const char * buf = mp_obj_str_get_data (name_obj , & len );
155+
156+ return wrap_result (__syscall2 (SYS_COMPUTER_SET_ARCHITECTURE , (int ) buf , (int ) len ));
157+ }
158+
159+ MP_DEFINE_CONST_FUN_OBJ_1 (ucomputer_set_architecture_obj , ucomputer_set_architecture );
160+
161+
131162STATIC const mp_rom_map_elem_t ucomputer_module_globals_table [] = {
132163 {MP_ROM_QSTR (MP_QSTR___name__ ), MP_ROM_QSTR (MP_QSTR_ucomputer )},
133164
@@ -141,20 +172,28 @@ STATIC const mp_rom_map_elem_t ucomputer_module_globals_table[] = {
141172 {MP_ROM_QSTR (MP_QSTR_pop_signal ), MP_ROM_PTR (& ucomputer_pop_signal_obj )},
142173
143174 // machine
144- {MP_ROM_QSTR (MP_QSTR_get_cost_per_tick ), MP_ROM_PTR (& ucomputer_get_cost_per_tick_obj )},
145- {MP_ROM_QSTR (MP_QSTR_last_error ), MP_ROM_PTR (& ucomputer_last_error_obj )},
175+ {MP_ROM_QSTR (MP_QSTR_get_last_error ), MP_ROM_PTR (& ucomputer_get_last_error_obj )},
146176
147177 // beep
148178 {MP_ROM_QSTR (MP_QSTR_beep ), MP_ROM_PTR (& ucomputer_beep_obj )},
149179
150180 // users
151- {MP_ROM_QSTR (MP_QSTR_users ), MP_ROM_PTR (& ucomputer_users_obj )},
181+ {MP_ROM_QSTR (MP_QSTR_get_users ), MP_ROM_PTR (& ucomputer_get_users_obj )},
152182 {MP_ROM_QSTR (MP_QSTR_add_user ), MP_ROM_PTR (& ucomputer_add_user_obj )},
153183 {MP_ROM_QSTR (MP_QSTR_remove_user ), MP_ROM_PTR (& ucomputer_remove_user_obj )},
154184
155185 // address
156186 {MP_ROM_QSTR (MP_QSTR_get_computer_address ), MP_ROM_PTR (& ucomputer_get_computer_address_obj )},
157187 {MP_ROM_QSTR (MP_QSTR_get_tmp_address ), MP_ROM_PTR (& ucomputer_get_tmp_address_obj )},
188+
189+ // energy
190+ {MP_ROM_QSTR (MP_QSTR_get_energy ), MP_ROM_PTR (& ucomputer_get_energy_obj )},
191+ {MP_ROM_QSTR (MP_QSTR_get_max_energy ), MP_ROM_PTR (& ucomputer_get_max_energy_obj )},
192+
193+ // architecture
194+ {MP_ROM_QSTR (MP_QSTR_get_architectures ), MP_ROM_PTR (& ucomputer_get_architectures_obj )},
195+ {MP_ROM_QSTR (MP_QSTR_get_architecture ), MP_ROM_PTR (& ucomputer_get_architecture_obj )},
196+ {MP_ROM_QSTR (MP_QSTR_set_architecture ), MP_ROM_PTR (& ucomputer_set_architecture_obj )},
158197};
159198
160199STATIC MP_DEFINE_CONST_DICT (ucomputer_module_globals , ucomputer_module_globals_table );
0 commit comments