int main(int argc, char **argv) { long i = 0; //Waiting counter long led = 0; //Bits to lit for (i=0; i<=3; i++) turnOffLed(i); init1sTimer0(); while (serial_getc_nb() > 255) { turnOffLed(led); led++; if (led == 4) led = 0; turnOnLed(led); launchAndWaitTimer0(); } return 0; }
#include <3048fone.h> #include "h8_3048fone.h" volatile int count1=-1;/*LED0用カウンタ -1の時は休止中*/ volatile int count2=-1;/*LED1用カウンタ -1の時は休止中*/ main() { initLed(); initPushSW();/*PushSWの初期化*/ initTimer1Int(10000); /*時間割り込み10000μsec=10msec ch1使用*/ E_INT(); /*CPU割り込み許可*/ startTimer1(); /*時間割り込みタイマスタートch1*/ while(1) { if ((count1==-1 || 50<count1) && checkPushSW(0)==1) { count1=0; turnOnLed(0); } else if (100<count1 && count1<200) { turnOffLed(0); } else if (200<count1 && count1<300) { /*200カウントで2秒経過*/ turnOnLed(0); } else if (300<count1) { count1=-1; turnOffLed(0); } if ((count2==-1 || 50<count2) && checkPushSW(1)==1) { count2=0; turnOnLed(1); } else if (100<count2 && count2<200) { turnOffLed(1); } else if (200<count2 && count2<300) { /*200カウントで2秒経過*/ turnOnLed(1); } else if (200<count2) { /*200カウントで2秒経過*/ count2=-1; turnOffLed(1); } } }
main() { initLed(); while(1) { turnOnLed(0); turnOffLed(1); waitmsec(1000); turnOffLed(0); turnOnLed(1); waitmsec(1000); } }
void DigitalLed::switchLedPinState() { if (m_ledPinState == HIGH) { turnOffLed(); } else { turnOnLed(); } }
DigitalLed::DigitalLed(int ledPinNumber) { m_blinkTimer = 0L; m_isBlinking = false; m_activeTimer = 0L; m_isActive = false; setLedPinNumber(ledPinNumber); turnOffLed(); }
main() { int i; initLed(); /*LEDの初期化*/ while(1) { turnOnLed(1); /*LED1のON*/ waitmsec(11); turnOffLed(1); /*LED1のOFF*/ waitmsec(11); } }
int main(int argc, char **argv) { serial_init(); serial_puts("\r\nPortal - Still alive\r\n"); long *address = (long *)(&partition_begin); long allTime = 0; initPE6(); long time = *address; address ++; long duration = *address; address ++; long waveLenght = *address; short c = 256; short previousLed = time%4; short currentLed = previousLed; while ((time != 0xFFFFFFFF || duration != 0xFFFFFFFF || waveLenght != 0xFFFFFFFF) && c > 255) { currentLed = time%4 == previousLed ? (time+1) % 4 : time % 4; turnOnLed(currentLed); allTime = time+duration; c = serial_getc_nb(); initMsTimer0(duration); playWaveLenghtMm(waveLenght); launchAndWaitTimer0(); shutUp(); address ++; turnOffLed(currentLed); previousLed = currentLed; time = *address; address ++; duration = *address; address ++; waveLenght = *address; } unsigned int a = 0; asm volatile("bx %0"::"r"(a)); return 0; }
int command(String param) { char *pointer = NULL; char *cstring = new char[param.length() + 1]; char **args = NULL; // always one argument int argCount = 1; int argIndex = 0; Serial.print("Event Received! -> "); Serial.println(param); // get our c string out for usage later strcpy(cstring, param.c_str()); // count args pointer = strchr(cstring,','); while (pointer != NULL) { pointer = strchr(pointer+1,','); argCount++; } args = (char **) malloc(sizeof(char*) * argCount); if (args != NULL) { pointer = strtok(cstring, ","); while (pointer != NULL) { args[argIndex++] = pointer; pointer = strtok(NULL, ","); } // if values per motor then left comes first, right second in args bool moving = false; if (strcmp("stop", args[0]) == 0 && argCount == 1) { robotController->changeState(ROBOT_STOPPED); } else if (strcmp("forward", args[0]) == 0 && argCount >= 1) { robotController->changeState(ROBOT_FORWARD); moving = true; } else if (strcmp("turnLeft", args[0]) == 0 && argCount >= 1) { robotController->changeState(ROBOT_TURNING_LEFT); moving = true; } else if (strcmp("turnRight", args[0]) == 0 && argCount >= 1) { robotController->changeState(ROBOT_TURNING_RIGHT); moving = true; } else if (strcmp("backward", args[0]) == 0 && argCount >= 1) { robotController->changeState(ROBOT_BACKWARD); moving = true; } else if (strcmp("setSpeed", args[0]) == 0 && argCount == 2) { unsigned int speed = strtoul(args[1], NULL, 10); if (speed != UINTMAX_MAX) { robotController->setRobotSpeed(speed); } } else if (strcmp("calibrateTurning", args[0]) == 0 && argCount == 2) { unsigned int turnLengthMs = strtoul(args[1], NULL, 10); if (turnLengthMs != UINTMAX_MAX) { robotController->calibrateTurning(turnLengthMs); } } else if (strcmp("calibrateSpeed", args[0]) == 0 && argCount == 3) { unsigned int leftCal = strtoul(args[1], NULL, 10); unsigned int rightCal = strtoul(args[2], NULL, 10); if (leftCal != UINTMAX_MAX && rightCal != UINTMAX_MAX) { robotController->calibrateSpeed(leftCal, rightCal); } } else if (strcmp("sendCalibration", args[0]) == 0 && argCount == 1) { eventController->queueEvent(PUBLISH_EVENT_CALIBRATION); eventController->queueEvent(PUBLISH_EVENT_HAS_FAILED); } else if (strcmp("calibrateFriction", args[0]) == 0 && argCount == 2) { unsigned int friction = strtoul(args[1], NULL, 10); if (friction != UINTMAX_MAX) { robotController->calibrateFriction(friction); } } else if (strcmp("resetFailed", args[0]) == 0 && argCount == 1) { robotController->resetFailed(); } else if (strcmp("calibrateDirection", args[0]) == 0 && argCount == 3) { unsigned int leftDir = strtoul(args[1], NULL, 10); unsigned int rightDir = strtoul(args[2], NULL, 10); if (rightDir != UINTMAX_MAX && leftDir != UINTMAX_MAX) { robotController->calibrateDirection(leftDir, rightDir); } } else if (strcmp("ledState", args[0]) == 0 && argCount == 2) { unsigned int state = strtoul(args[1], NULL, 10); turnOffLed(state == 1); } if (moving && argCount == 3) { Serial.println(args[1]); Serial.println(args[2]); robotController->motorsSetDistance(args[1], getDistanceUnitFromArg(args[2])); } free(args); } delete cstring; return 0; }
int main(int argc,char *argv[]){ float VINT; float VOUT; if( argc > 2 ) { VINT = atof(argv[1]); // input voltage VOUT = atof(argv[2]); // voltage output } else{ printf("\n Something goes wrong... \n"); printf("\n Usage: testSPI Vin Vout \n"); printf("\n Where Vin and Vout are float values \n"); return EXIT_FAILURE; } if (rp_Init() != RP_OK) { fprintf(stderr, "Red Pitaya API init failed!\n"); return EXIT_FAILURE; } turnOnLed(0); sleep(1); // All pin startup definition OutputPinDefinition(); UpdatePinStructures(); WriteAllBus(); setVoltageClamp(); int *tab; int i =0; tab = malloc(4*sizeof(int)); turnOnLed(1); sleep(1); printf("\n Test of function FindResistors: \n"); tab = FindResistors(VINT,VOUT); for(i=0;i<4;i++) printf("%d\n",tab[i]); // Tale vrstica naredi izpis za izračunane komponente turnOffLed(1); turnOnLed(2); sleep(1); setVCResistorsValue(VINT, VOUT); turnOffLed(2); sleep(1); /* printf("\n TESTING SPI-WRITE COMMAND \n"); turnOnLed(3); sleep(1); //char *data[3]={0x254, 0x33, 0}; char *data="AaBbCc"; //char *data[8] ={0x01, 0x05, 0x00, 0x20, 0xFF, 0x00, 0x00, 0x00}; if (write_spi(data, strlen(data))<0){ printf("Write to SPI FAILED"); } turnOffLed(3); sleep(1);*/ turnOffLed(0); rp_Release(); return EXIT_SUCCESS; }
void ExportService::startUSBExport() { // Logger::instance()->writeRecord(Logger::severity_level::debug, "Exporter Module", Q_FUNC_INFO, "Starting Exporter Service"); /* * Creates the object of the classes and then move these objects to execute as thread. * Make the connection between threads. Starts both threads. */ // m_exporter->moveToThread(m_exportThread); // QObject::connect(m_exportThread, SIGNAL(started()), m_exporter, SLOT(startExport())); DeviceThread::instance()->moveToThread(m_daemonThread); QObject::connect(m_daemonThread, SIGNAL(started()), DeviceThread::instance(), SLOT(startListening())); QObject::connect(DeviceThread::instance(), SIGNAL(exportToDevice(QString)), m_exporter, SLOT(exportAction(QString))); QObject::connect(DeviceThread::instance(), SIGNAL(turnLedOff()), m_exporter, SLOT(turnOffLed())); // m_exportThread->start(); m_daemonThread->start(); m_exporter->startExport(); }
void DigitalLed::resetLed() { stopBlinkingLed(); turnOffLed(); m_activeTimer = 0L; m_isActive = false; }