void beep() { wyswietl_LCD("BEEP..BEEP"); buzzer_on(); _delay_ms(500); buzzer_off(); _delay_ms(500); buzzer_on(); _delay_ms(700); buzzer_off(); }
void mymain(void) { // set GPKCON0: output (led1-led4: use GPK4-GPK7) GPKCON0 = 0x11110000; // set all led off (write 1 to be off) GPKDAT = 0x000000f0; // set GPF14 as output GPFCON |= 1<<28; GPFCON &= ~(1<<29); // set GPN0 as input GPNCON = 0; while(1) { if ( !(GPNDAT & (1<<0)) ) { buzzer_on(); led_on(0); } else { buzzer_off(); led_off(0); } } }
void keypad_buzzer(void) { unsigned int keyStatus; while(1) { keyStatus = keyScan(); if(keyStatus) { buzzer_on(); delay(); buzzer_off(); } else buzzer_off(); } }
void buzzer() { buzzer_on(); ////_delay_ms(1000); buzzer_off(); }
//-------------------------------------------------------------------------------- // start the main function here //-------------------------------------------------------------------------------- int main(void) { float battery_low = 0; init_devices(); packet_valid = 0;// initialise valid packet variable to 0 // initially calculate the battery voltage UCSRB = 0x00; ADMUX = 0x26; //select ADC input 6 battery_voltage = ADC_conversion(); UCSRB = 0x98; flag2 = 0; while(1) { // flag2 will rise once in 10sec and calculates the Battery voltage // and enables the UART communication if(flag2 == 1) { ADMUX = 0x26; //select ADC input 6 battery_voltage = ADC_conversion(); UCSRB = 0x98; flag2 = 0; } // if battery voltage is less then battery threshold value ,buzzer beeps battery_low = (battery_voltage * 0.041) + 0.7; // battery voltage caluculation if(battery_low < BATTERY_TRHRESHOLD) { buzzer_on(); _delay_ms(200); buzzer_off();_delay_ms(200);} // following function beeps the buzzer twice after sucessfully reciving 10 packets // from the master(FireBird-V Hexapod robot) if(flag1 == 0) { if(communication_proper_count > 10) { flag1 = 1; buzzer_on(); _delay_ms(400); buzzer_off();_delay_ms(400); buzzer_on(); _delay_ms(400); buzzer_off();_delay_ms(400); } } } }
/** **************************************************************************************** * @brief Handles button press after cancel the jitter. * * @param[in] msgid Id of the message received * @param[in] param None * @param[in] dest_id TASK_APP * @param[in] src_id TASK_APP * * @return If the message was consumed or not. **************************************************************************************** */ int app_button_timer_handler(ke_msg_id_t const msgid, void const *param, ke_task_id_t const dest_id, ke_task_id_t const src_id) { switch(msgid) { case APP_SYS_BUTTON_1_TIMER: // make sure the button is pressed if(gpio_read_pin(BUTTON1_PIN) == GPIO_LOW) { if(APP_IDLE == ke_state_get(TASK_APP)) { struct app_proxr_env_tag *app_proxr_env = &app_env.proxr_ev; if(!app_proxr_env->enabled) { // start adv app_gap_adv_start_req(GAP_GEN_DISCOVERABLE|GAP_UND_CONNECTABLE, app_env.adv_data, app_set_adv_data(GAP_GEN_DISCOVERABLE), app_env.scanrsp_data, app_set_scan_rsp_data(app_get_local_service_flag()), GAP_ADV_FAST_INTV1, GAP_ADV_FAST_INTV2); #if (QN_DEEP_SLEEP_EN) // prevent entering into deep sleep mode sleep_set_pm(PM_SLEEP); #endif #if (FB_OLED) ke_timer_set(APP_OLED_STATE_DISPlAY_TIMER,TASK_APP,20); #endif } } else if(APP_ADV == ke_state_get(TASK_APP)) { // stop adv app_gap_adv_stop_req(); #if (QN_DEEP_SLEEP_EN) // allow entering into deep sleep mode sleep_set_pm(PM_DEEP_SLEEP); #endif #if (FB_OLED) ke_timer_set(APP_OLED_STATE_DISPlAY_TIMER,TASK_APP,20); #endif } } break; case APP_SYS_BUTTON_2_TIMER: if(gpio_read_pin(BUTTON2_PIN) == GPIO_LOW) { buzzer_off(); } break; default: ASSERT_ERR(0); break; } return (KE_MSG_CONSUMED); }
//function for indication of eye-bling and raw values when removed from head void Eye_Blink () { if (Eye_Enable) { if (On_Flag==1 && Off_Flag==0) { if ((Avg_Raw>Theshold_Eyeblink) && (Avg_Raw<350)) //eye-blink detected { p++; buzzer_on(); _delay_ms(500); buzzer_off(); if(p==2){ stop(); velocity(240,240); left(); _delay_ms(650); stop(); run(); p=0; } } else { if (Avg_Raw>350) //Raw data values indication { buzzer_on();_delay_ms(50);buzzer_off(); //Sensor removed from head, bot stops. stop(); On_Flag==0;Off_Flag==1; } } } else { PORTJ=0x00; } } else //Device is paired { PORTJ=0x01; stop(); } }
//------------------------------------------------------------------------------ int board_init(void) { u32 v1, v2; //printf("board_init\n"); /* arch number of the board */ gd->bd->bi_arch_number = MACH_TYPE_DAVINCI_EVM; /* address of boot parameters */ gd->bd->bi_boot_params = 0x0000100; //LINUX_BOOT_PARAM_ADDR; /* if workarounds are needed */ ka_errata_workarounds(); /* Disable SSI Clock */ word_write(KA_REGIF_BASE, word_read(KA_REGIF_BASE) & 0xffdfffff); // printf("Status %x\n", word_read(SDSW_M1_STATUS)); //setenv ("bootdelay", "8"); v1 = word_read(0x1ffc00); v2 = word_read(0x208000); #ifndef BOOT_FROM_SD if (v2 == 0xe1a00000 || v2 == 0xe3a00000) setenv ("bootf", "mmc init; go 208000"); else if (v2 == 0x56190527) setenv ("bootf", "mmc init; bootm 208000"); else if (v1 == 0xe1a00000 || v1 == 0xe3a00000) setenv ("bootf", "mmc init; go 1ffc00"); else if (v1 == 0x56190527) setenv ("bootf", "mmc init; bootm 1ffc00"); else #endif { //setenv ("bootf", "mmc init; fatload mmc 1 208000 image; go 208000"); setenv ("bootf", "run boot_sd"); //printf("v1 %x v2 %x\n", v1, v2); buzzer_off(); } /* Enable UART */ /*word_write(UART_LCR, 0x83); word_write(UART_INTR, 0x00); word_write(UART_RECV, 0x28); //baudrate=19200,12MHz word_write(UART_LCR, 0x03); */ /* Close PLL */ /* Power on required peripherals */ //timer_init(); //word_write(GPIO_OUTPUT, 0x66); return(0); }
void checkState(int t) { while(t>0) { buzzer_on(); _delay_ms(50); buzzer_off(); _delay_ms(200); t--; } }
/** @brief Low Battery alarm to be called for example with 1 Hz */ void beep_on_low_voltage(void) { if (global_data.battery_voltage < BATTERY_LOW_VOLTAGE_ALARM) { buzzer_toggle(); } else { buzzer_off(); } }
//Main Function void buzzer(void) { init_devices_buzzer(); for(int i=0;i<1;i++) { buzzer_on(); _delay_ms(1000); //delay buzzer_off(); _delay_ms(1000); //delay } }
void sh_cmd1(void) { // time_tt t = {}; // clean_lcd(BACK_COL); // gettime(&t); buzzer_init(); buzzer_on(); udelay(1000*1000); buzzer_off(); udelay(1000*1000); }
/** **************************************************************************************** * @brief Handles alert stop timer. * * @param[in] msgid APP_PROXR_ALERT_STOP_TO * @param[in] param Null * @param[in] dest_id TASK_APP * @param[in] src_id TASK_NONE * * @return If the message was consumed or not. * @description * This handler is used to request the Application to start the alert on the device * considering the indicated alert level. The handler may be triggered on two conditions: * The IAS alert level characteristic has been written to a valid value, in which case * alert_lvl will be set to the IAS alert level value. * A disconnection with a reason other than the normal local/remote link terminations has * been received, in which case alert_lvl will be set to the LLS alert level value. * The Application actions following reception of this indication are strictly implementation * specific (it may try to reconnect to the peer and stop alert upon that, or timeout the * alert after acertain time, please see the specification) **************************************************************************************** */ int app_proxr_alert_to_handler(ke_msg_id_t const msgid, void *param, ke_task_id_t const dest_id, ke_task_id_t const src_id) { // Stop proxr alert buzzer_off(); //app_proxr_env->alert_lvl = 0; QPRINTF("alert_stop_timer_handler.\r\n"); return (KE_MSG_CONSUMED); }
/** Turn left at an intersection. */ void turn_left(){ buzzer_off(); motion_set(0x05); velocity(100,100); _delay_ms(1000); while(1){ print_sensor_data(); read_sensors(); if(Center_white_line < W_THRESHOLD) break; } velocity(0,0); }
void buzzer_beep(int n) { int i; for (i = 0; i < n; i++) { buzzer_on(); mdelay(100); buzzer_off(); mdelay(100); } }
//Main Function int main(void) { init_devices(); while(1) { if((PINE & 0x80) == 0x80) //switch is not pressed { buzzer_off(); //Turn off buzzer PORTJ = 0x00; //Turn off bargraph LEDs } else { buzzer_on(); //Turn on buzzer PORTJ = 0xFF; //Turn on bargraph LEDs } } }
void update_node() { if(to_process ==1) { lcd_cursor(2,13); lcd_string(store); visited =atoi(store); check_node[visited]=1; to_process=0; buzzer_off(); for(k=0;k<4;k++) store[k]=0; forward(); return; } }
int isPlus() { if((Left_white_line >0x20 && Center_white_line>0x20) || (Right_white_line >0x20 && Center_white_line>0x20)) { buzzer_on(); _delay_ms(100); buzzer_off(); _delay_ms(100); return 1; } else { return 0; } }
int move_bot() { init_sensor_values(); while(checkobstacle()==0) {} buzzer_off(); if(checkintersection() == 1) { //communicate with coordinator comintersection(); stop(); _delay_ms(100); return 0; } else { follow(); return 1; } }
int detect_program_bin(void) { int ret, size, count; u32 *buf; buf = (u32 *)0xe00000; fat_register_device(&mmc_blk_dev,1); //buzzer_off(); size = file_fat_read ("program.bin", buf, 128 * 1024); if (size > 1 && (buf[0] == 0xea000012 || buf[0] == 0x120000ea)) { buzzer_on(0); run_command("go e00000", 0); buzzer_off(); } //buzzer_off(); return 0; }
void main() { buzzer_off(); pcf_8591_init(); timer0_init(); timer1_init(); while(1) { switch(mod) { case 1: re = pcf_8591_rd(); delay(20); l3 = weight(re,l3); break; case 2: TR0 = 0; if(leixing == 1) { display(mod,ht1,0); Delay1000ms(ht1); ht1--; if(ht1 == 0) mod = 1; } else { display(mod,ht2,0); Delay1000ms(ht2); ht2--; if(ht2 == 0) mod = 1; } break; case 3: break; } } }
void menu_key_test(void) { u8 i; u16 bit; // cleanup screen and disable possible low bat warning buzzer_off(); key_beep(); menu_battery_low = 0; // it will be set automatically again battery_low_shutup = 0; // do full screen blink lcd_set_full_on(); delay_menu_always(2); while (btns(BTN_ENTER)) stop(); // wait for release of ENTER lcd_clear(); button_autorepeat(0); // disable autorepeats btnra(); // show intro text lcd_chars("KEY"); lcd_update_stop(); // wait for key while (1) { if (btnl(BTN_BACK | BTN_ENTER)) break; for (i = 0, bit = 1; i < 16; i++, bit <<= 1) { if (btn(bit)) { key_beep(); lcd_chars(key_ids[i]); if (btnl(bit)) lcd_7seg(L7_L); else lcd_set(L7SEG, LB_EMPTY); lcd_update(); break; } } btnra(); stop(); } key_beep(); apply_model_config(); }
void detect(){ if(USART1_RX_vect()==0xAA){ //check SYNC byte 1 if(USART1_RX_vect()==0xAA){ //check SYNC byte 2 payloadlength=USART1_RX_vect(); if(payloadlength < 169) { //Payload length can not be greater than 169 generatedChecksum = 0; for(int i = 0; i < payloadlength; i++) { payloaddata[i] = USART1_RX_vect(); //Read payload into memory generatedChecksum += payloaddata[i]; } checksum = USART1_RX_vect(); //Read checksum byte from stream generatedChecksum = 255 - generatedChecksum; if(checksum == generatedChecksum) { //Checking whether checksum received is correct. If buzzer turns on then packet is correct. buzzer_on();_delay_ms(100);buzzer_off();_delay_ms(100); } } } } }
int test(void) { int i = 0; led_init(); buzzer_init(); k1_init(); while(1) { if(k1_is_down()) { buzzer_on(); led_on(i%4 + 1); delay(1); buzzer_off(); led_off(i%4 + 1); delay(1); i++; } } return 0; }
/** Inicjalizacja urządzeń wejścia / wyjścia. */ void ioinit(void) { uint8_t i; hd44780_init(); hd44780_outcmd(HD44780_CLR); hd44780_wait_ready(); hd44780_outcmd(HD44780_ENTMODE(1, 0)); hd44780_wait_ready(); hd44780_outcmd(HD44780_DISPCTL(1, 1, 1)); hd44780_wait_ready(); hd44780_outcmd(HD44780_CGADDR(0)); for(i=0; i<64; i++) { hd44780_outdata(pgm_read_byte(&extraChar[i])); } TCCR1B = _BV(WGM12) | _BV(CS11); // licznik / 8 - wyzerwoanie na porownanie TIMSK = _BV(OCIE1A); // przerwanie na porownanie wartosci OCR1A = TAU1; // warto licznika porownania usart_init(UBRR_VALUE); onewire_init(); twi_init(); outputs_init(); top_off_init(); qbuttons_init(); ui_init(); BUZZER_DDR |= _BV(BUZZER_SWITCH); buzzer_off(); wdt_enable(WDTO_2S); }
/** Go forward by a certain specified number of steps. */ void go_distance(unsigned char x) { reset_shaft_counters(); forward(); velocity(100,100); PORTJ = 0x00; while(1){ read_sensors(); print_sensor_data(); if( Front_IR_Sensor<0xF0) { stop(); buzzer_on(); } else { forward(); buzzer_off(); } if((ShaftCountLeft + ShaftCountRight)*5 > x*10) break; } velocity(0,0); }
/** **************************************************************************************** * @brief Show proxr alert. User can add their own code here to show alert. **************************************************************************************** */ static void usr_proxr_alert(struct proxr_alert_ind *param) { // If it is PROXR_LLS_CHAR writting indication, don't alert, // otherwise (PROXR_IAS_CHAR, disconnect) to alert if (param->char_code == PROXR_IAS_CHAR || app_proxr_env->enabled == false) { if(param->alert_lvl == 2) { buzzer_on(BUZZ_VOL_HIGH); ke_timer_set(APP_PROXR_ALERT_STOP_TIMER, TASK_APP, 500); // 5 seconds } else if(param->alert_lvl == 1) { buzzer_on(BUZZ_VOL_LOW); ke_timer_set(APP_PROXR_ALERT_STOP_TIMER, TASK_APP, 500); // 5 seconds } else { buzzer_off(); ke_timer_clear(APP_PROXR_ALERT_STOP_TIMER, TASK_APP); } } }
__EXPORT int nsh_archinitialize(void) { int result; message("\n"); /* configure always-on ADC pins */ stm32_configgpio(GPIO_ADC1_IN0); stm32_configgpio(GPIO_ADC1_IN10); stm32_configgpio(GPIO_ADC1_IN11); stm32_configgpio(GPIO_UART_SBUS_INVERTER); #ifdef CONFIG_RC_INPUTS_TYPE(RC_INPUT_SBUS) stm32_gpiowrite(GPIO_UART_SBUS_INVERTER, 1); #else stm32_gpiowrite(GPIO_UART_SBUS_INVERTER, 0); #endif /* configure the high-resolution time/callout interface */ hrt_init(); /* configure CPU load estimation */ #ifdef CONFIG_SCHED_INSTRUMENTATION cpuload_initialize_once(); #endif /* initial BUZZER state */ drv_buzzer_start(); buzzer_off(BUZZER_EXT); /* initial LED state */ drv_led_start(); led_off(LED_AMBER); led_off(LED_BLUE); led_off(LED_GREEN); led_off(LED_EXT1); led_off(LED_EXT2); /* Configure SPI-based devices */ message("[boot] Initializing SPI port 1\n"); spi1 = up_spiinitialize(1); if (!spi1) { message("[boot] FAILED to initialize SPI port 1\r\n"); led_on(LED_AMBER); return -ENODEV; } /* Default SPI1 to 1MHz and de-assert the known chip selects. */ SPI_SETFREQUENCY(spi1, 10000000); SPI_SETBITS(spi1, 8); SPI_SETMODE(spi1, SPIDEV_MODE3); SPI_SELECT(spi1, GPIO_SPI_CS_MS5611, false); SPI_SELECT(spi1, GPIO_SPI_CS_EXP_MS5611, false); SPI_SELECT(spi1, GPIO_SPI_CS_EXP_MPU6000, false); SPI_SELECT(spi1, GPIO_SPI_CS_EXP_HMC5983, false); SPI_SELECT(spi1, GPIO_SPI_CS_EXP_WIFI_EEPROM, false); up_udelay(20); message("[boot] Successfully initialized SPI port 1\r\n"); // message("[boot] Initializing Wireless Module\n"); // wireless_archinitialize(); message("[boot] Initializing SPI port 2\n"); spi2 = up_spiinitialize(2); if (!spi2) { message("[boot] FAILED to initialize SPI port 2\r\n"); led_on(LED_AMBER); return -ENODEV; } /* Default SPI2 to 1MHz and de-assert the known chip selects. */ SPI_SETFREQUENCY(spi2, 10000000); SPI_SETBITS(spi2, 8); SPI_SETMODE(spi2, SPIDEV_MODE3); SPI_SELECT(spi2, GPIO_SPI_CS_MPU6000, false); SPI_SELECT(spi2, GPIO_SPI_CS_IMU_MS5611, false); SPI_SELECT(spi2, GPIO_SPI_CS_IMU_MPU6000, false); SPI_SELECT(spi2, GPIO_SPI_CS_IMU_HMC5983, false); SPI_SELECT(spi2, GPIO_SPI_CS_IMU_EEPROM, false); message("[boot] Successfully initialized SPI port 2\n"); /* Get the SPI port for the microSD slot */ message("[boot] Initializing SPI port 3\n"); spi3 = up_spiinitialize(3); if (!spi3) { message("[boot] FAILED to initialize SPI port 3\n"); led_on(LED_AMBER); return -ENODEV; } /* Default SPI3 to 1MHz and de-assert the known chip selects. */ SPI_SETFREQUENCY(spi3, 10000000); SPI_SETBITS(spi3, 8); SPI_SETMODE(spi3, SPIDEV_MODE3); SPI_SELECT(spi3, GPIO_SPI_CS_DATAFLASH, false); SPI_SELECT(spi3, GPIO_SPI_CS_EEPROM, false); SPI_SELECT(spi3, GPIO_SPI_CS_SDCARD, false); message("[boot] Successfully initialized SPI port 3\n"); /* Now bind the SPI interface to the MMCSD driver */ result = mmcsd_spislotinitialize(CONFIG_NSH_MMCSDMINOR, CONFIG_NSH_MMCSDSLOTNO, spi3); if (result != OK) { message("[boot] FAILED to bind SPI port 3 to the MMCSD driver\n"); led_on(LED_AMBER); return -ENODEV; } message("[boot] Successfully bound SPI port 3 to the MMCSD driver\n"); return OK; }
void menu_global_setup(void) { u8 item = 0; u8 item_val = 0; // now selecting item global_setup_t func = gs_config[item]; // cleanup screen and disable possible low bat warning buzzer_off(); key_beep(); menu_battery_low = 0; // it will be set automatically again backlight_set_default(BACKLIGHT_MAX); backlight_on(); lcd_clear(); lcd_segment(LS_MENU_MODEL, LS_ON); lcd_segment_blink(LS_MENU_MODEL, LB_INV); lcd_segment_blink(LS_MENU_NAME, LB_INV); lcd_update(); func(0); // show current value while (1) { btnra(); stop(); if (btnl(BTN_BACK | BTN_ENTER)) break; if (btn(BTN_ENTER)) { if (item > 0) { // not for firmware version key_beep(); item_val = (u8)(1 - item_val); if (item_val) { // changing value lcd_chars_blink(LB_SPC); } else { // selecting item lcd_chars_blink(LB_OFF); } } } else if (btn(BTN_ROT_ALL)) { if (item_val) { // change item value func(1); lcd_chars_blink(LB_SPC); } else { // select another item func(0xff); // un-show labels if (btn(BTN_ROT_L)) { if (item) item--; else item = GS_CONFIG_SIZE - 1; } else { if (++item >= GS_CONFIG_SIZE) item = 0; } func = gs_config[item]; func(0); // show current value } lcd_update(); } } func(0xff); // un-show labels, apply resets beep(60); lcd_clear(); config_global_save(); apply_global_config(); }
// shut up battery low beeper static void kf_battery_low_shutup(u8 *id, u8 *param, u8 flags, s16 *pv) { battery_low_shutup = 1; buzzer_off(); }