void hexbright::init_hardware() { // These next 8 commands are for reference and cost nothing, // as we are initializing the values to their default state. pinModeFast(DPIN_PWR, OUTPUT); digitalWriteFast(DPIN_PWR, LOW); pinModeFast(DPIN_RLED_SW, INPUT); pinModeFast(DPIN_GLED, OUTPUT); pinModeFast(DPIN_DRV_MODE, OUTPUT); pinModeFast(DPIN_DRV_EN, OUTPUT); digitalWriteFast(DPIN_DRV_MODE, LOW); digitalWriteFast(DPIN_DRV_EN, LOW); #if (DEBUG!=DEBUG_OFF) // Initialize serial busses Serial.begin(9600); Wire.begin(); Serial.println("DEBUG MODE ON"); #endif #if (DEBUG!=DEBUG_OFF && DEBUG!=DEBUG_PRINT) if(DEBUG==DEBUG_LIGHT) { // do a full light range sweep, (printing all light intensity info) set_light(0,1000,update_delay*1002); } else if (DEBUG==DEBUG_TEMP) { set_light(0, MAX_LEVEL, NOW); } else if (DEBUG==DEBUG_LOOP) { // note the use of TIME_MS/update_delay. set_light(0, MAX_LEVEL, 2500/update_delay); } #ifdef FREE_RAM Serial.print("Ram available: "); Serial.print(freeRam()); Serial.println("/1024 bytes"); #endif #ifdef FLASH_CHECKSUM Serial.print("Flash checksum: "); Serial.println(flash_checksum()); #endif #endif // DEBUG!=DEBUG_OFF #ifdef ACCELEROMETER enable_accelerometer(); #endif // was this power on from battery? if so, it was a button press, even if it was too fast to register. read_charge_state(); if(get_charge_state()==BATTERY) press_button(); continue_time = micros(); }
void hexbright::init_hardware() { // We just powered on! That means either we got plugged // into USB, or the user is pressing the power button. pinModeFast(DPIN_PWR, INPUT); digitalWriteFast(DPIN_PWR, LOW); // Initialize GPIO pinModeFast(DPIN_RLED_SW, INPUT); pinModeFast(DPIN_GLED, OUTPUT); pinModeFast(DPIN_DRV_MODE, OUTPUT); pinModeFast(DPIN_DRV_EN, OUTPUT); digitalWriteFast(DPIN_DRV_MODE, LOW); digitalWriteFast(DPIN_DRV_EN, LOW); #if (DEBUG!=DEBUG_OFF) // Initialize serial busses Serial.begin(9600); Wire.begin(); Serial.println("DEBUG MODE ON"); #endif #if (DEBUG!=DEBUG_OFF && DEBUG!=DEBUG_PRINT) if(DEBUG==DEBUG_LIGHT) { // do a full light range sweep, (printing all light intensity info) set_light(0,1000,update_delay*1002); } else if (DEBUG==DEBUG_TEMP) { set_light(0, MAX_LEVEL, NOW); } else if (DEBUG==DEBUG_LOOP) { // note the use of TIME_MS/update_delay. set_light(0, MAX_LEVEL, 2500/update_delay); } #ifdef FREE_RAM Serial.print("Ram available: "); Serial.print(freeRam()); Serial.println("/1024 bytes"); #endif #ifdef FLASH_CHECKSUM Serial.print("Flash checksum: "); Serial.println(flash_checksum()); #endif #endif // DEBUG!=DEBUG_OFF #ifdef ACCELEROMETER enable_accelerometer(); #endif continue_time = micros(); }
void hexbright::init_hardware() { // These next 8 commands are for reference and cost nothing, // as we are initializing the values to their default state. pinModeFast(DPIN_PWR, OUTPUT); digitalWriteFast(DPIN_PWR, LOW); pinModeFast(DPIN_RLED_SW, INPUT); pinModeFast(DPIN_GLED, OUTPUT); pinModeFast(DPIN_DRV_MODE, OUTPUT); pinModeFast(DPIN_DRV_EN, OUTPUT); digitalWriteFast(DPIN_DRV_MODE, LOW); digitalWriteFast(DPIN_DRV_EN, LOW); #if (DEBUG!=DEBUG_OFF) // Initialize serial busses Serial.begin(9600); Wire.begin(); Serial.println("DEBUG MODE ON"); #endif #if (DEBUG!=DEBUG_OFF && DEBUG!=DEBUG_PRINT) #ifdef FREE_RAM Serial.print("Ram available: "); Serial.print(freeRam()); Serial.println("/1024 bytes"); #endif #ifdef FLASH_CHECKSUM Serial.print("Flash checksum: "); Serial.println(flash_checksum()); #endif #endif //(DEBUG!=DEBUG_OFF && DEBUG!=DEBUG_PRINT) #ifdef ACCELEROMETER enable_accelerometer(); #endif // was this power on from battery? if so, it was a button press, even if it was too fast to register. read_charge_state(); if(get_charge_state()==BATTERY) press_button(); continue_time = micros(); }