void my_LED_set_all_brightness( uint8_t amount ) { /* LedControl led_ctrl; led_ctrl.mode = LedControlMode_brightness_set_all; led_ctrl.amount = amount; led_ctrl.index = 0x00; // dummy LED_control( &led_ctrl ); */ LED_control( LedControl_brightness_set_all, amount ); } // my_LED_set_all_brightness
task usercontrol() { // User control code here, inside the loop while (true) { LED_control(); shooter_variable_speed_control(); drive_control(); feed_control(); } }
void LED_control_capability( TriggerMacro *trigger, uint8_t state, uint8_t stateType, uint8_t *args ) { CapabilityState cstate = KLL_CapabilityState( state, stateType ); switch ( cstate ) { case CapabilityState_Initial: // Only use capability on press break; case CapabilityState_Debug: // Display capability name print("LED_control_capability(mode,amount)"); return; default: return; } // Set the input structure LedControl control = (LedControl)args[0]; uint8_t arg = (uint8_t)args[1]; // Interconnect broadcasting #if defined(ConnectEnabled_define) // By default send to the *next* node, which will determine where to go next extern uint8_t Connect_id; // connect_scan.c uint8_t addr = Connect_id + 1; // Send interconnect remote capability packet // generatedKeymap.h extern const Capability CapabilitiesList[]; // Broadcast layerStackExact remote capability (0xFF is the broadcast id) Connect_send_RemoteCapability( addr, LED_control_capability_index, state, stateType, CapabilitiesList[ LED_control_capability_index ].argCount, args ); #endif // Modify led state of this node LED_control( control, arg ); }
void cliFunc_ledCtrl( char* args ) { char* curArgs; char* arg1Ptr; char* arg2Ptr = args; LedControl control; // First process mode curArgs = arg2Ptr; CLI_argumentIsolation( curArgs, &arg1Ptr, &arg2Ptr ); // Stop processing args if no more are found if ( *arg1Ptr == '\0' ) return; control.mode = numToInt( arg1Ptr ); // Next process amount curArgs = arg2Ptr; CLI_argumentIsolation( curArgs, &arg1Ptr, &arg2Ptr ); // Stop processing args if no more are found if ( *arg1Ptr == '\0' ) return; control.amount = numToInt( arg1Ptr ); // Finally process led index, if it exists // Default to 0 curArgs = arg2Ptr; CLI_argumentIsolation( curArgs, &arg1Ptr, &arg2Ptr ); control.index = *arg1Ptr == '\0' ? 0 : numToInt( arg1Ptr ); // Process request LED_control( &control ); }
void LED_control_capability( uint8_t state, uint8_t stateType, uint8_t *args ) { // Display capability name if ( stateType == 0xFF && state == 0xFF ) { print("LED_control_capability(mode,amount,index)"); return; } // Only use capability on press // TODO Analog if ( stateType == 0x00 && state == 0x03 ) // Not on release return; // XXX // ISSI Chip locks up if we spam updates too quickly (might be an I2C bug on this side too -HaaTa) // Make sure we only send an update every 30 milliseconds at most // It may be possible to optimize speed even further, but will likely require serious time with a logic analyzer uint8_t currentTime = (uint8_t)systick_millis_count; int8_t compare = (int8_t)(currentTime - LED_control_timer) & 0x7F; if ( compare < 30 ) { return; } LED_control_timer = currentTime; // Set the input structure LedControl *control = (LedControl*)args; // Interconnect broadcasting #if defined(ConnectEnabled_define) uint8_t send_packet = 0; uint8_t ignore_node = 0; // By default send to the *next* node, which will determine where to go next extern uint8_t Connect_id; // connect_scan.c uint8_t addr = Connect_id + 1; switch ( control->mode ) { // Calculate the led address to send // If greater than the Total hannels // Set address - Total channels // Otherwise, ignore case LedControlMode_brightness_decrease: case LedControlMode_brightness_increase: case LedControlMode_brightness_set: // Ignore if led is on this node if ( control->index < LED_TotalChannels ) break; // Calculate new led index control->index -= LED_TotalChannels; ignore_node = 1; send_packet = 1; break; // Broadcast to all nodes // XXX Do not set broadcasting address // Will send command twice case LedControlMode_brightness_decrease_all: case LedControlMode_brightness_increase_all: case LedControlMode_brightness_set_all: send_packet = 1; break; } // Only send interconnect remote capability packet if necessary if ( send_packet ) { // generatedKeymap.h extern const Capability CapabilitiesList[]; // Broadcast layerStackExact remote capability (0xFF is the broadcast id) Connect_send_RemoteCapability( addr, LED_control_capability_index, state, stateType, CapabilitiesList[ LED_control_capability_index ].argCount, args ); } // If there is nothing to do on this node, ignore if ( ignore_node ) return; #endif // Modify led state of this node LED_control( control ); }