コード例 #1
0
// ---------------------------------------------------------------------------
void draw_WifiScan() {
    Screen_DrawBorder(_lng(WIFI_SCAN_TITLE));
    
    if(WifiScan_First == 1) {
      // first draw screen, on second draw scan for wifi networks
      WifiScan_First = 2; 
    }
    
    else if(WifiScan_First == 2) {
       WifiScan_First = 0;
       doScan(); 
       return;
    }
    
    if(WifiScan_First == 0) {
      // draw menu 
      Menu_Draw(menu_wifi_scan, 1, 8);
    } else {
      // draw 'scanning...'
      GLCDD_Rect r;      
      
      r.x = SCREEN_W / 2 - GLCDD_StringWidth(fnt_dejavu_9b, _lng(SCANNING)) / 2;
      r.y = SCREEN_H / 2 - GLCDD_FontHeight(fnt_dejavu_9b) / 2;
      r.w = SCREEN_W - 4;
      r.h = -1;
      GLCDD_Print(fnt_dejavu_9b, &r, _lng(SCANNING));
    }
}
コード例 #2
0
// ---------------------------------------------------------------------------
void draw_Snooze() {
  GLCDD_Rect r;
  char buffer[4];

  Screen_DrawBorder(_lng(SNOOZE));

  // increase/decrease minutes  
  int8_t rotary = IO_GetRotaryValue();
  if(rotary != 0) {
   Snooze_Minutes += rotary;
   if(Snooze_Minutes < 0) Snooze_Minutes = 0;
   if(Snooze_Minutes > 59) Snooze_Minutes = 59;
  }
  
  if(IO_GetButton(0)) {
    if(Snooze_Minutes == 0) {
      Snooze_IsSnooze = 0; 
    } else {
      Snooze_IsSnooze = 1;
      Snooze_Time = time(NULL) + (60 * Snooze_Minutes);
    }
    // go back to now playing
    Screen_Goto(SCREEN_NOW_PLAYING); 
  }

  // draw minutes
  sprintf(buffer, "%d", Snooze_Minutes);

  int width = GLCDD_StringWidth(fnt_dejavu_9, buffer);
  r.x = SCREEN_W / 2 - 5 - 3 - GLCDD_StringWidth(fnt_dejavu_9, _lng(MINUTES)) / 2 ;

  GLCDD_XBMDraw((uint8_t*)img_setter, r.x, SCREEN_H / 2 + 4 - 12, 9, 24);
  r.x += 5 - width / 2;
  r.y = SCREEN_H / 2 + 4 - GLCDD_FontHeight(fnt_dejavu_9) / 2;
  r.w = 32;
  r.h = -1;
  GLCDD_Print(fnt_dejavu_9, &r, buffer);
  r.x += width / 2 + 4 + 6;
  r.w = 64;
  GLCDD_Print(fnt_dejavu_9, &r, _lng(MINUTES));
  
  
}
コード例 #3
0
// ---------------------------------------------------------------------------
void Screen_DrawBorder(char* title) {
 GLCDD_Rectangle(0, 0, SCREEN_W, SCREEN_H, 0);
 GLCDD_Rectangle(0, 0, SCREEN_W, 7, 1);
 GLCDD_ClearPixel(0, 0);
 GLCDD_ClearPixel(SCREEN_W - 1, 0);
 GLCDD_ClearPixel(0, SCREEN_H - 1);
 GLCDD_ClearPixel(SCREEN_W - 1, SCREEN_H - 1);
 
 fnt_screen_border->color = 1;
 GLCDD_Rect r;
 r.x = SCREEN_W / 2 - GLCDD_StringWidth(fnt_screen_border, title) / 2;
 r.y = 0;
 r.w = SCREEN_W;
 r.h = -1;
 GLCDD_Print(fnt_screen_border, &r, title);
 fnt_screen_border->color = 0;
 
 if(isSnooze()) {
   GLCDD_ClearEx(SCREEN_W - 12, 1, SCREEN_W - 5, 5);
   GLCDD_XBMDraw((uint8_t*)img_snooze, SCREEN_W - 12, 1, 8, 5);
 }
}
コード例 #4
0
// ---------------------------------------------------------------------------
void draw_NowPlaying() {
  char buffer[512];
  int idx;

  Screen_DrawBorder(_lng(NOW_PLAYING_TITLE));
  
  GLCDD_Rect r;
  
  FILE* f = fopen(SONG_FILE, "r");
  if(f == NULL) return;
  ignore_result(fgets(buffer, 512, f));
  fclose(f);
 
  // split songname - artist
  int i, found = 0;
  for(i = 0; i < strlen(buffer); i++) {
   if(buffer[i] == ' ' && buffer[i+1] == '-' && buffer[i+2] == ' ') {
     buffer[i+1] = 0;
     found = 1;
     break;
   }
  }
  if(!found) i = -3;
 
  r.x = 6;
  r.y = 14;
  r.w = SCREEN_W - 12;
  r.h = -1;
  idx = i + 3 + (NowPlaying_Sel == 1 ? NowPlaying_ScrollOffset : 0);
  // limit scrolling
  if(NowPlaying_Sel == 1) {
    if(GLCDD_StringWidth(fnt_dejavu_9b, &buffer[idx]) + r.x < r.w) {
      NowPlaying_ScrollDir *= -1; 
      if(idx > i + 3) idx--;
    }
    else if(NowPlaying_ScrollOffset < 0) {
      NowPlaying_ScrollDir *= -1;
      idx++;
    }
  }
  // draw title
  if(strlen(&buffer[idx]) > 1) GLCDD_Print(fnt_dejavu_9b, &r, &buffer[idx]); else GLCDD_Print(fnt_dejavu_9b, &r, _lng(NO_TITLE));
  
  r.y = 29;
  idx = (NowPlaying_Sel == 2 ? NowPlaying_ScrollOffset : 0);
  // limit scrolling
  if(NowPlaying_Sel == 2) {
    if(GLCDD_StringWidth(fnt_dejavu_9, &buffer[idx]) + r.x < r.w) {
      NowPlaying_ScrollDir *= -1; 
      if(idx > 0) idx--;
    }
    else if(NowPlaying_ScrollOffset < 0) {
      NowPlaying_ScrollDir *= -1;
      idx++;
    }
  }
  // draw artist
  if(strlen(&buffer[idx]) > 1) GLCDD_Print(fnt_dejavu_9, &r, &buffer[idx]); else GLCDD_Print(fnt_dejavu_9, &r, _lng(NO_ARTIST));
  
 
  // get station
  f = fopen(CURRENT_STATION_FILE, "r");
  if(f == NULL) return;
  ignore_result(fgets(buffer, 512, f));
  fclose(f);
 
  r.y = 44;
  idx = (NowPlaying_Sel == 3 ? NowPlaying_ScrollOffset : 0);
  // limit scroling
  if(NowPlaying_Sel == 3) {
    if(GLCDD_StringWidth(fnt_dejavu_9, &buffer[idx]) + r.x < r.w) {
      NowPlaying_ScrollDir *= -1; 
      if(idx > 0) idx--;
    }
    else if(NowPlaying_ScrollOffset < 0) {
      NowPlaying_ScrollDir *= -1;
      idx++;
    }
  }
  // draw station
  if(strlen(buffer) <= 2) GLCDD_Print(fnt_dejavu_9, &r, _lng(NO_STATION)); else GLCDD_Print(fnt_dejavu_9, &r, &buffer[idx]);
  
  // draw scrolling text if line is selected
  if(!NowPlaying_ShowMenu) {
    int8_t rotary = IO_GetRotaryValue();
    if(rotary != 0) {
      NowPlaying_ScrollOffset = 0;
      NowPlaying_ScrollDir = 1;
    }
    NowPlaying_Sel += rotary;
    if(NowPlaying_Sel < 0) NowPlaying_Sel = 0;
    if(NowPlaying_Sel >= 4) NowPlaying_Sel = 3;
    
    GLCDD_Invert(4, 12 + (NowPlaying_Sel - 1) * 15, SCREEN_W - 4, 12 + 2 + GLCDD_FontHeight(fnt_dejavu_9) + (NowPlaying_Sel - 1) * 15);
    
    if(NowPlaying_Sel != 0) NowPlaying_ScrollOffset += NowPlaying_ScrollDir;
  }
  
  
  // we play from usb and can therefore skip the song
  if(strncmp(buffer, _lng(USB), strlen(_lng(USB))) == 0) {
   GLCDD_RectRounded(SCREEN_W - 36, SCREEN_H - 14, 32, 10, 1);
   fnt_dejavu_9->color = 1;
   r.x = SCREEN_W - 29;
   r.y = SCREEN_H - 13;
   r.w = 28;
   r.h = -1;
   GLCDD_Print(fnt_dejavu_9, &r, _lng(NEXT));
   fnt_dejavu_9->color = 0;
   
   if(IO_GetButton(0)) {
      char cmd[64];
      sprintf(cmd, "%s &", Settings_Get("programs", "next_song"));
      ignore_result(system(cmd));
   }
  } else {
    // if no station is played, don't show menu
    if(strlen(buffer) <= 2) return; 
    
    // we play a station, enable context menu
    if(!NowPlaying_ShowMenu && IO_GetButton(0)) {
     createContextMenu();
     NowPlaying_ShowMenu = 1; 
    }
    
    if(NowPlaying_ShowMenu) Menu_Draw(menu_now_playing, 32, 16);
    
    int selection = Menu_IsChosen(menu_now_playing);
    if(selection != -1) {
      if(selection == 1) { 
	// snooze
	Screen_Goto(SCREEN_SNOOZE);
      }      
      if(selection == 2) { // add as favorite
	printf("add station '%s' as favorite\r\n", NowPlaying_CurStation.name);
	// add to favorite list
	ArrayList* stations = readStations();
	AList_Add(stations, &NowPlaying_CurStation);
	writeStations(stations);
	AList_Delete(stations, AList_Length(stations) - 1);
	freeStations(stations);
	AList_Destroy(stations);
      }
      
      NowPlaying_ShowMenu = 0; 
      Screen_ForceRedraw();
    }
  }
}
コード例 #5
0
ファイル: screenGraph.c プロジェクト: An00bIS47/gbMon2
void displayBorder(){
	//GLCDD_Line(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2)
	
	GLCDD_Rect r;
	
	r.x = 6;
	r.w = 128 - 12;
	r.h = -1;
	
	fnt_spaceLex_5=createFont(spaceLex_5);
	
	//GLCDD_Rectangle(0,  9, 128, 16, 0);
	//GLCDD_Rectangle(2, 11, 124, 12, 0);
	
	r.x = 1;
	r.y = 17;
	r.w = GLCDD_StringWidth(fnt_spaceLex_5, "40");
	GLCDD_Printf(fnt_spaceLex_5, 0, &r, "40");
	
	r.y = 27;
	r.w = GLCDD_StringWidth(fnt_spaceLex_5, "30");
	GLCDD_Printf(fnt_spaceLex_5, 0, &r, "30");
	
	r.y = 37;
	r.w = GLCDD_StringWidth(fnt_spaceLex_5, "20");
	GLCDD_Printf(fnt_spaceLex_5, 0, &r, "20");
	
	r.y = 47;
	r.w = GLCDD_StringWidth(fnt_spaceLex_5, "10");
	GLCDD_Printf(fnt_spaceLex_5, 0, &r, "10");
	
	// Vertikale Linie
	GLCDD_Line(10,20,10,60);
	
	// 40
	GLCDD_Line(8,20,10,20);
	
	// 35
	GLCDD_Line(9,25,10,25);
	
	// 30
	GLCDD_Line(8,30,10,30);
	
	// 25
	GLCDD_Line(9,35,10,35);
	
	// 20
	GLCDD_Line(8,40,10,40);
	
	// 15
	GLCDD_Line(9,45,10,45);
	
	// 10
	GLCDD_Line(8,50,10,50);
	
	// 5
	GLCDD_Line(9,55,10,55);
	
	// Horizontale Linie
	GLCDD_Line(10,60,118,60);
	
	curPos = 10;
}