void alsa_volume(const Arg *a) { long vol = a->i; snd_mixer_handle_events(alsa.handle); vol += volume_get(); volume_set(vol); }
void button(int min, int max) { if (digitalRead(buttonA_pin) == 1) { //volume_set(max); //play_track(); printf("\nbutton A\n"); } if (digitalRead(buttonB_pin) == 1) { printf("\nbutton B\n"); max = volume_set(max+1); } if (digitalRead(buttonC_pin) == 1) { printf("\nbutton C\n"); } if (digitalRead(buttonD_pin) == 1) { printf("\nbutton D\n"); max = volume_set(max-1); } }
void sculpture_start() { printf("\n\n***7x7 sculpture wait for signal***\n\n"); for (;;) { int x = analogRead(ultrasound_pin); int vol_min = 30, vol_max = 85; // button(vol_min,vol_max); if (x<100) { play_track(); volume_set(vol_max); sculpture_play(vol_min, vol_max); } printf("ultrasound = %d\n",x); delay(200); } }
int main (int argc, char **argv) { int count; int type; if ((fd = open("/dev/dbox/avs0",O_RDWR)) <= 0) { perror("open"); return -1; } if (ioctl(fd,AVSIOGTYPE,&type)< 0) { perror("can't get avs-type:"); close(fd); return -1; } switch(type) { case CXA2092: printf("CXA2092 found\n"); break; case CXA2126: printf("CXA2126 found\n"); break; case STV6412: printf("STV6412 found\n"); break; default: printf("unknown avs type\n"); close(fd); return -1; } for(count=1;count<argc;count++) { /* -h or --help */ if ((strcmp("-h",argv[count]) == 0) || (strcmp("--help",argv[count]) == 0)) { help(argv[0]); } /* -s or --show */ else if ((strcmp("-s",argv[count]) == 0) || (strcmp("--show",argv[count]) == 0)) { routing_show(); volume_show(); zcd_show(); fnc_show(); ycm_show(); fblk_show(); } /* -v or --vol */ else if ((strcmp("-v",argv[count]) == 0) || (strcmp("--vol",argv[count]) == 0)) { if (argc == count+1) { printf("No volume given\n"); exit(1); } else if ((argv[count+1][0] < 0x30) || (argv[count+1][0] > 0x39)) { printf("No volume given\n"); exit(1); } else { count++; volume_set(atoi(argv[count])); } } /* -ttv or --trash-my-tv */ else if ((strcmp("-ttv",argv[count]) == 0) || (strcmp("--trash-my-tv",argv[count]) == 0)) { printf("\nGet your TV repaired for a low price here at our sponsor: http://www.dvb-shop.de\n\n greetings -Hunz :-]\n\n"); while(1) { fnc_set(0); printf("."); // fflush(stdout); usleep(500); fnc_set(1); printf("O"); // fflush(stdout); usleep(500); } } /* -zcd or --zero-cross-detector */ else if ((strcmp("-zcd",argv[count]) == 0) || (strcmp("--zero-cross-detector",argv[count]) == 0)) { if (argc == count+1) { printf("No status given\n"); exit(1); } else { count++; if (strcmp("on",argv[count]) == 0) zcd_set(1); else zcd_set(0); } } /* -ycm */ else if ((strcmp("-ycm",argv[count]) == 0) || (strcmp("--y-c-mix",argv[count]) == 0)) { if (argc == count+1) { printf("No status given\n"); exit(1); } else { count++; if (strcmp("on",argv[count]) == 0) ycm_set(1); else ycm_set(0); } } /* -fnc */ else if ((strcmp("-fnc",argv[count]) == 0) || (strcmp("--video-function-switch-control",argv[count]) == 0)) { if (argc == count+1) { printf("No value given\n"); exit(1); } else if ((argv[count+1][0] < 0x30) || (argv[count+1][0] > 0x39)) { printf("No value given\n"); exit(1); } else { count++; fnc_set(atoi(argv[count])); } } /* -fblk */ else if ((strcmp("-fblk",argv[count]) == 0) || (strcmp("--video-fast-blanking-control",argv[count]) == 0)) { if (argc == count+1) { printf("No value given\n"); exit(1); } else if ((argv[count+1][0] < 0x30) || (argv[count+1][0] > 0x39)) { printf("No value given\n"); exit(1); } else { count++; fblk_set(atoi(argv[count])); } } /* -m or --mute */ else if ((strcmp("-m",argv[count]) == 0) || (strcmp("--mute",argv[count]) == 0)) { volume_mute(); } /* -u or --unmute */ else if ((strcmp("-u",argv[count]) == 0) || (strcmp("--unmute",argv[count]) == 0)) { volume_unmute(); } /* -rv or --route-video */ else if ((strcmp("-rv",argv[count]) == 0) || (strcmp("--route-video",argv[count]) == 0)) { if (argc < count+3) { printf("No source/destination given\n"); exit(1); } else if ((argv[count+1][0] < 0x31) || (argv[count+1][0] > 0x33) || (argv[count+2][0] < 0x30) || (argv[count+2][0] > 0x37)) { printf("No source/destination given\n"); exit(1); } else { count+=2; set_video_source(argv[count-1][0]-0x30,argv[count][0]-0x30); } } /* -ra or --route-audio */ else if ((strcmp("-ra",argv[count]) == 0) || (strcmp("--route-audio",argv[count]) == 0)) { if (argc < count+3) { printf("No source/destination given\n"); exit(1); } else if ((argv[count+1][0] < 0x31) || (argv[count+1][0] > 0x33) || (argv[count+2][0] < 0x30) || (argv[count+2][0] > 0x37)) { printf("No source/destination given\n"); exit(1); } else { count+=2; set_audio_source(argv[count-1][0]-0x30,argv[count][0]-0x30); } } else { help(argv[0]); } } close(fd); return 0; }
void indicator_music_mouse(Indicator *indicator, XButtonPressedEvent *ev) { if(ev->type != ButtonPress) { Window w; int tmp; int x, y; unsigned int mask; XQueryPointer(dpy, menu.window, &w, &w, &tmp, &tmp, &x, &y, &mask); menu.selected=-1; if(x>=0&&y>=0&&x<menu.w&&y<menu.h) { if(mask&0x100&&y/bh==1) { int sliderw=menu.w-10*2; snd_mixer_handle_events(alsa.handle); volume_set(100*(x-10)/sliderw); } menu.selected=y/bh; menu.button=x>=menu.w/2-BUTTON_W*3/2&&x<menu.w/2+BUTTON_W*2/2?(x-(menu.w/2-BUTTON_W*3/2))/BUTTON_W:-1; } indicator_music_expose(indicator, menu.window); return; } if(ev->window==menu.window) { int sliderw=menu.w-10*2; int item=ev->y/bh; struct MEDIAPLAYER *mp; if(item==0) { snd_mixer_handle_events(alsa.handle); mute_set(!mute_get()); } else if(item==1) { if(ev->x>=10&&ev->x<menu.w-10) { snd_mixer_handle_events(alsa.handle); volume_set(100*(ev->x-10)/sliderw); } } else { int i; for(mp=mediaplayer, i=2; mp; mp=mp->next, i+=5) if(item==i) { mediaplayer_raise(mp->id); indicator->active=False; menu_close(); break; } else if(item==i+4&&menu.button>=0) { mediaplayer_action(mp->id, menu.button); indicator_music_expose(indicator, ev->window); } return; } indicator_music_expose(indicator, ev->window); return; } switch(ev->button) { case Button1: case Button3: if((indicator->active=!indicator->active)) menu_open(indicator); else menu_close(); return; case Button4: snd_mixer_handle_events(alsa.handle); volume_set(volume_get()+6); break; case Button5: snd_mixer_handle_events(alsa.handle); volume_set(volume_get()-4); break; } if(indicator->active) indicator_music_expose(indicator, menu.window); }