static void notify_cb (const char *name, XSettingsAction action, XSettingsSetting *setting, void *data) { int row; char *text[4]; switch (action) { case XSETTINGS_ACTION_NEW: text[NAME] = (char *)name; text[TYPE] = text[VALUE] = text[SERIAL] = ""; row = gtk_clist_insert (GTK_CLIST (settings_clist), 0, text); gtk_clist_set_row_data_full (GTK_CLIST (settings_clist), row, g_strdup (name), (GDestroyNotify)g_free); update_row (row, setting); break; case XSETTINGS_ACTION_CHANGED: row = find_row (name); update_row (row, setting); break; case XSETTINGS_ACTION_DELETED: row = find_row (name); gtk_clist_remove (GTK_CLIST (settings_clist), row); break; } }
void play_module(struct Player *p, struct Module *m, unsigned long count) { // main play routine //p->ticks++; if(p->ticks >= p->speed) { // check for pattern break if (p->p_break) { p->order_index++; p->row = p->p_break_x * 10 + p->p_break_y; p->pos = &m->pattern_data[m->order[p->order_index] * m->channels * 64]; p->p_break = 0; p->p_break_x = 0; p->p_break_y = 0; } update_row(p, m, count); p->ticks = 0; p->row++; if(p->row < 64) p->pos+=4; else { p->order_index++; p->row=0; p->pos = &m->pattern_data[m->order[p->order_index] * m->channels * 64]; } } update_tick(p); p->ticks++; }
void set_array_green(unsigned char rows) { update_row(0, rows, 0); //write 0x00,0xFF,0x00 to SPI //check SPSR register, see datasheet for bit //Strobe LED Latch }
int main(int argc, char **argv) { initialize(); initialize_TIMER0(); clear_array(); PORTC = 0; USART_send_string("Currently outputing color: \n"); while(1){ for(unsigned int i = 0; i < 8; ++i){ PORTE = i; switch (state){ case RED: //PORTE = 1; update_row(224,0,0); checkState(); break; case GREEN: update_row(0,7,0); checkState(); break; case YELLOW: led_off(); update_row(yellowRow,0,0); update_row(yellowRow,0,0); update_row(yellowRow,yellowRow,0); update_row(yellowRow,0,0); update_row(yellowRow,0,0); led_off(); checkState(); break; } } } }
void led_red( uint8_t x, uint8_t y ) { /* Let's index this from the top left, like a normal screen. * However, the LED array is indexed in hardware from the bottom right, * with the bit position controlling y, and PORTE controlling x. */ //to reverse a column, you can use (1 << 7) >> (column & 0x07) //to reverse the row, you can use (7 - (row & 0x07)) | (PORTE & 0xF8) PORTE = x; update_row((1<<y), 0, 0); }
// This method regenerates the sensor model's probabilities using the // Gabbiani LGMD model and the given standard deviation for the Gaussian // blurring operation for bins near the ones actually "pointed to" by the // [TTI, LGMD] pairs returned by the Gabbiani model. // // DEVNOTE: The sigma provided to this function is actually added to the // m_sigma member variable. This allows client behaviours to increment or // decrement the current sigma value rather than provide an actual sigma. // The very first sigma will be read from the config file (see // constructor). void SensorModel::update(float dsigma) { AutoMutex M(m_mutex) ; // Record new standard deviation const float R = row_size() ; m_sigma = clamp(m_sigma + dsigma, 0.1f, R) ; // Begin with a uniform distribution for each state const int N = m_prob.size() ; std::fill_n(m_prob.begin(), N, 1/R) ; // Apply Gabbiani LGMD model to generate causal likelihoods const float step = row_step()/4.0f ; const range<float> tti = conf(m_name + "_tti_range", Params::tti_range()) ; for (float t = tti.min(); t <= tti.max(); t += step) update_row(t, GabbianiModel::spike_rate(t), m_sigma) ; }
void browse(int type, int nc, int nr, void *in) { WINDOW *pdlscr, *wmenu, *wscroll, *warray, *whlab, *wvlab, *wtmp; char s[CHBUF],echobuf[CHBUF],line[CHBUF]; chtype ch; int i,j,eps,ioff,joff,iecho; int ncols, nrows, mycols; extern int colwid, dcols, drows, width[]; pdlscr = initscr(); /* sets LINES, COLS (which aren't macro constants...) */ clear(); /* Clear the screen before we start drawing */ colwid = width[type]; ncols = (COLS-HLAB)/colwid; dcols = MIN(nc,ncols); mycols = dcols*colwid; nrows = LINES-3; drows = MIN(nr,nrows); cbreak(); noecho(); nonl(); intrflush(pdlscr,FALSE); keypad(pdlscr,TRUE); /* Menu bar */ wmenu = subwin(pdlscr,1,COLS,0,0); wvlab = subwin(pdlscr,1,mycols,1,HLAB); wscroll= subwin(pdlscr,drows,mycols+HLAB,2,0); warray = subwin(wscroll,drows,mycols,2,HLAB); whlab = subwin(wscroll,drows,HLAB,2,0); keypad(warray,TRUE); scrollok(pdlscr,TRUE); scrollok(wscroll,TRUE); wmenu = subwin(pdlscr,1,COLS,0,0); sprintf(s,"Perldl data browser: type %d, (%d,%d), type q to quit\n", type,nc,nr); mvwaddstr(wmenu,0,10,s); wrefresh(wmenu); for (i=0;i<dcols;i++) { update_vlab(wvlab,i,0); } wrefresh(wvlab); for (j=0;j<drows;j++) { update_hlab(whlab,j,0); } wrefresh(whlab); for (j=0;j<drows;j++) { update_row(warray,j,0,0,type,nc,in); } i = j = eps = 0; ioff = joff = 0; while (tolower(ch=mvwgetch(warray,j-joff,(i-ioff)*colwid+ MIN(eps,colwid-2))) != 'q') { /* #define ECHOCH */ #ifdef ECHOCH sprintf(echobuf,"%8o",ch); mvwaddstr(wmenu,0,iecho,echobuf); iecho = (iecho < 72) ? iecho+8 :0; wrefresh(wmenu); #endif switch (ch) { case KEY_LEFT: case KEY_RIGHT: case KEY_UP: case KEY_DOWN: case '\t': case '\015': if (eps) { line[eps] = '\0'; set_value(i,j,type,nc,in,line); } set_cell(warray,i,j,ioff,joff,type,nc,in); eps = 0; wrefresh(warray); break; case '\b': case KEY_DL: case 0177: if (eps) { eps--; mvwaddch(warray,j-joff,(i-ioff)*colwid+MIN(eps,colwid-2),' '); wrefresh(warray); } continue; default: if (!eps && ch >= 32 && ch <= 127) { clear_cell(warray,i-ioff,j-joff); wrefresh(warray); } mvwaddch(warray,j-joff,(i-ioff)*colwid+MIN(eps,colwid-2),ch|A_UNDERLINE); line[eps++]=ch; continue; } switch (ch) { case KEY_LEFT: i = (i<2)?0:i-1; if (i-ioff == -1) { ioff--; wtmp = newwin(1,mycols-colwid,1,HLAB); overwrite(wvlab,wtmp); mvwin(wtmp,1,HLAB+colwid); overwrite(wtmp,wvlab); delwin(wtmp); update_vlab(wvlab,0,ioff); wtmp = newwin(drows,mycols-colwid,2,HLAB); overwrite(warray,wtmp); mvwin(wtmp,2,HLAB+colwid); overwrite(wtmp,warray); delwin(wtmp); update_col(warray,0,ioff,joff,type,nc,in); wrefresh(warray); wrefresh(wvlab); } break; case KEY_RIGHT: case '\t': i = (i>nc-2)?nc-1:i+1; if (i-ioff == dcols) { ioff++; wtmp = newwin(1,mycols-colwid,1,HLAB+colwid); overwrite(wvlab,wtmp); mvwin(wtmp,1,HLAB); overwrite(wtmp,wvlab); delwin(wtmp); update_vlab(wvlab,dcols-1,ioff); wtmp = newwin(drows,mycols-colwid,2,HLAB+colwid); overwrite(warray,wtmp); mvwin(wtmp,2,HLAB); overwrite(wtmp,warray); delwin(wtmp); update_col(warray,dcols-1,ioff,joff,type,nc,in); wrefresh(warray); wrefresh(wvlab); } break; case KEY_UP: j = (j<2)?0:j-1; if (j-joff == -1) { joff--; wscrl(wscroll,-1); wrefresh(wscroll); update_hlab(whlab,0,joff); wrefresh(whlab); update_row(warray,0,ioff,joff,type,nc,in); wrefresh(warray); } break; case KEY_DOWN: case '\015': j = (j>nr-2)?nr-1:j+1; if (j-joff == drows) { joff++; wscrl(wscroll,1); wrefresh(wscroll); update_hlab(whlab,drows-1,joff); wrefresh(whlab); update_row(warray,drows-1,ioff,joff,type,nc,in); wrefresh(warray); } break; } } nl(); echo(); nocbreak(); endwin(); }
void __cdecl thread(void *args) { int id; HANDLE *event_list=args; HANDLE event=0,event_idle=0; if(args==0) return; event=event_list[0]; event_idle=event_list[1]; if(event==0 || event_idle==0) return; printf("worker thread started\n"); while(TRUE){ stop_thread_menu(FALSE); SetEvent(event_idle); id=WaitForSingleObject(event,INFINITE); if(id==WAIT_OBJECT_0){ stop_thread_menu(TRUE); strncpy(localinfo,taskinfo,sizeof(localinfo)); printf("db=%s\n",localinfo); switch(task){ case TASK_CLOSE_DB: { DB_TREE *db=0; if(find_db_tree(localinfo,&db)){ intelli_del_db(db->name); mdi_remove_db(db); set_status_bar_text(ghstatusbar,0,"closed %s",localinfo); } else set_status_bar_text(ghstatusbar,0,"cant find %s",localinfo); } break; case TASK_OPEN_DB_AND_TABLE: case TASK_OPEN_DB: { DB_TREE *db=0; char *table; int result=FALSE; table=strstr(localinfo,";TABLE="); if(table!=0){ table[0]=0; table++; } SetWindowText(ghstatusbar,"opening DB"); if(!wait_for_treeview()){ SetWindowText(ghstatusbar,"treeview error"); break; } acquire_db_tree(localinfo,&db); if(!mdi_open_db(db)){ char str[512]; mdi_remove_db(db); _snprintf(str,sizeof(str),"Cant open %s",localinfo); str[sizeof(str)-1]=0; MessageBox(ghmainframe,str,"OPEN DB FAIL",MB_OK); SetWindowText(ghstatusbar,"error opening DB"); set_focus_after_open(db); } else{ intelli_add_db(db->name); set_focus_after_open(db); reassign_tables(db); if(task==TASK_OPEN_DB_AND_TABLE && table!=0 && strncmp(table,"TABLE=",sizeof("TABLE=")-1)==0){ table+=sizeof("TABLE=")-1; ResetEvent(event); task_open_table(db->name,table); continue; } else{ load_tables_if_empty(db); if(keep_closed) close_db(db); result=TRUE; } } set_status_bar_text(ghstatusbar,0,"open DB %s %s",result?"done":"failed",keep_closed?"(closed DB)":""); } break; case TASK_GET_COL_INFO: { void *db=0; char table[80]={0}; sscanf(localinfo,"DB=0x%08X;TABLE=%79[ -~]",&db,table); table[sizeof(table)-1]=0; if(db!=0){ int result; set_status_bar_text(ghstatusbar,0,"getting col info for %s",table); result=get_col_info(db,table); if(keep_closed) close_db(db); if(result) set_status_bar_text(ghstatusbar,0,"col info done, %s",keep_closed?"(closed DB)":""); set_focus_after_open(db); } } break; case TASK_GET_INDEX_INFO: { void *db=0; char table[80]={0}; sscanf(localinfo,"DB=0x%08X;TABLE=%79[ -~]",&db,table); table[sizeof(table)-1]=0; if(db!=0){ int result; set_status_bar_text(ghstatusbar,0,"getting index info for %s",table); result=get_index_info(db,table); if(keep_closed) close_db(db); if(result) set_status_bar_text(ghstatusbar,0,"index info done, %s",keep_closed?"(closed DB)":""); set_focus_after_open(db); } } break; case TASK_GET_FOREIGN_KEYS: { void *db=0; char table[80]={0}; sscanf(localinfo,"DB=0x%08X;TABLE=%79[ -~]",&db,table); table[sizeof(table)-1]=0; if(db!=0){ int result; set_status_bar_text(ghstatusbar,0,"getting foreign keys for %s",table); result=get_foreign_keys(db,table); if(keep_closed) close_db(db); if(result) set_status_bar_text(ghstatusbar,0,"index info done, %s",keep_closed?"(closed DB)":""); set_focus_after_open(db); } } break; case TASK_UPDATE_ROW: { int result=FALSE; void *win=0; int row=0; sscanf(localinfo,"WIN=0x%08X;ROW=%i",&win,&row); if(win!=0){ char *s=strstr(localinfo,"DATA="); if(s!=0){ s+=sizeof("DATA=")-1; result=update_row(win,row,s); if(keep_closed){ void *db=0; acquire_db_tree_from_win(win,&db); close_db(db); } } } set_status_bar_text(ghstatusbar,0,"update row %s %s", result?"done":"failed", keep_closed?"(closed DB)":""); } break; case TASK_DELETE_ROW: { int result=FALSE; void *win=0; int row=0; sscanf(localinfo,"WIN=0x%08X;ROW=%i",&win,&row); if(win!=0){ result=delete_row(win,row); if(keep_closed){ void *db=0; acquire_db_tree_from_win(win,&db); close_db(db); } } set_status_bar_text(ghstatusbar,0,"delete row %s", result?"done":"failed", (win!=0 && keep_closed)?"(closed DB)":""); } break; case TASK_INSERT_ROW: { int result=FALSE; void *win=0,*hlistview=0; sscanf(localinfo,"WIN=%08X,HLISTVIEW=0x%08X",&win,&hlistview); if(win!=0 && hlistview!=0){ int msg=IDOK; result=insert_row(win,hlistview); if(!result) msg=IDCANCEL; PostMessage(GetParent(hlistview),WM_USER,msg,hlistview); if(keep_closed){ void *db=0; acquire_db_tree_from_win(win,&db); close_db(db); } } set_status_bar_text(ghstatusbar,0,"inserting row %s %s", result?"done":"failed", (win!=0 && hlistview!=0 && keep_closed)?"(closed DB)":""); } break; case TASK_EXECUTE_QUERY: { void *win=0; int result=FALSE; win=strtoul(localinfo,0,0); if(win==0) mdi_get_current_win(&win); if(win!=0){ char *s=0; int size=0; reopen_db(win); mdi_create_abort(win); mdi_get_edit_text(win,&s,&size); if(s!=0){ sql_remove_comments(s,size); result=execute_sql(win,s,TRUE); free(s); } mdi_destroy_abort(win); if(keep_closed){ void *db=0; acquire_db_tree_from_win(win,&db); close_db(db); } set_focus_after_result(win,result); } if(!result) set_status_bar_text(ghstatusbar,0,"execute sql failed %s", keep_closed?"(closed DB)":""); } break; case TASK_NEW_QUERY: { void *db=0; find_selected_tree(&db); if(db!=0){ void *win=0; char *tname="new_query"; if(acquire_table_window(&win,tname)){ create_table_window(ghmdiclient,win); set_focus_after_result(win,FALSE); assign_db_to_table(db,win,tname); } } } break; case TASK_REFRESH_TABLES: case TASK_REFRESH_TABLES_ALL: { int result=FALSE; DB_TREE *db=0; SetWindowText(ghstatusbar,"refreshing tables"); if(acquire_db_tree(localinfo,&db)){ if(!mdi_open_db(db)){ mdi_remove_db(db); SetWindowText(ghstatusbar,"error opening DB"); } else{ intelli_add_db(db->name); result=refresh_tables(db,task==TASK_REFRESH_TABLES_ALL); if(keep_closed) close_db(db); } if(result) set_status_bar_text(ghstatusbar,0,"refreshed tables %s", keep_closed?"(closed DB)":""); } else SetWindowText(ghstatusbar,"error refreshing cant acquire table"); } break; case TASK_LIST_TABLES: { int result=FALSE; DB_TREE *db=0; SetWindowText(ghstatusbar,"listing tables"); if(acquire_db_tree(localinfo,&db)){ if(!mdi_open_db(db)){ mdi_remove_db(db); SetWindowText(ghstatusbar,"error opening DB"); } else{ intelli_add_db(db->name); result=get_table_list(db); if(keep_closed) close_db(db); } if(result){ set_status_bar_text(ghstatusbar,0,"done listing tables %s", keep_closed?"(closed DB)":""); }else{ SetWindowText(ghstatusbar,"error listing tables"); } } else SetWindowText(ghstatusbar,"error refreshing cant acquire tree"); } break; case TASK_LIST_PROCS: { int result=FALSE; DB_TREE *db=0; SetWindowText(ghstatusbar,"listing stored procedures"); if(acquire_db_tree(localinfo,&db)){ if(!mdi_open_db(db)){ mdi_remove_db(db); SetWindowText(ghstatusbar,"error opening DB"); } else{ intelli_add_db(db->name); result=get_proc_list(db); if(keep_closed) close_db(db); } if(result){ set_status_bar_text(ghstatusbar,0,"done listing stored procs %s", keep_closed?"(closed DB)":""); }else{ SetWindowText(ghstatusbar,"error listing stored procs"); } } else SetWindowText(ghstatusbar,"error refreshing cant acquire tree"); } break; case TASK_OPEN_TABLE: { int result=FALSE; char dbname[MAX_PATH*2]={0},table[80]={0},*p; p=strrchr(localinfo,';'); if(p!=0){ void *db=0; p[0]=0; strncpy(dbname,localinfo,sizeof(dbname)); strncpy(table,p+1,sizeof(table)); if(find_db_tree(dbname,&db)){ void *win=0; if(acquire_table_window(&win,table)){ char sql[256]={0}; create_table_window(ghmdiclient,win); open_db(db); assign_db_to_table(db,win,table); if(strchr(table,' ')!=0) _snprintf(sql,sizeof(sql),"SELECT * FROM [%s]",table); else _snprintf(sql,sizeof(sql),"SELECT * FROM %s",table); mdi_set_edit_text(win,sql); mdi_create_abort(win); result=execute_sql(win,sql,TRUE); mdi_destroy_abort(win); load_tables_if_empty(db); set_focus_after_result(win,result); if(keep_closed) close_db(db); } else free_window(win); } } if(!result) set_status_bar_text(ghstatusbar,0,"open table:%s %s %s", table,"failed",keep_closed?"(closed DB)":""); } break; case TASK_INTELLISENSE_ADD_ALL: { void *win=0; int result=FALSE; win=strtoul(localinfo,0,0); if(win==0) mdi_get_current_win(&win); if(win!=0){ reopen_db(win); mdi_create_abort(win); result=intellisense_add_all(win); mdi_destroy_abort(win); if(keep_closed){ void *db=0; acquire_db_tree_from_win(win,&db); close_db(db); } set_focus_after_result(win,FALSE); } if(!result) set_status_bar_text(ghstatusbar,0,"intellisense add all failed %s", keep_closed?"(closed DB)":""); } break; default: break; } } ResetEvent(event); } CloseHandle(event); hworker=0; }
void led_off( void ) { update_row( 0, 0, 0); }
void led_blue( uint8_t x, uint8_t y ) { PORTE = x; update_row(0, 0, (1 << y)); }
void led_green( uint8_t x, uint8_t y ) { PORTE = x; update_row(0, (1 << y), 0); }
void clear_array() { update_row( 0, 0, 0); }
void set_array_red(unsigned char rows) { update_row(rows, 0, 0); }
void set_array_blue(unsigned char rows) { update_row(0, 0, rows); }