Ejemplo n.º 1
0
int main(void)
{
	char *status;
        char *batt;
	char *tmmtl;
	char *tmgva;

	if (!(dpy = XOpenDisplay(NULL))) {
		fprintf(stderr, "dwmstatus: cannot open display.\n");
		return 1;
	}

	for (;;sleep(1)) {
                batt = battery();
		tmmtl = mktimes(tmfmt, tzmtl);
		tmgva = mktimes(tmfmt, tzgva);

		status = smprintf("%s | mtl: %s gva: %s",
				batt,tmmtl,tmgva);
		setstatus(status);
                free(batt);
		free(tmmtl);
		free(status);
	}

	XCloseDisplay(dpy);

	return 0;
}
Ejemplo n.º 2
0
static void cmd_lcd(Stream *chp, int argc, char* argv[]) 
{   
   clear();
   label(0,0, "APRS");
   flag(32,0, "i", true);
   flag(41,0, "a", false);
   flag(50,0, "g", true);
   flag(59,0, "d", true);
   battery(70,3,2);
   hLine(0,10,66);
   
   writeText(0,15,"144.800 MHz");
   writeText(0,26,"LA7ECA-7");
   writeText(0,37,"W1,W2-1,SAR");  
   
   flush();
}
DataSourceBattery::DataSourceBattery(SystemSnapshot *parent) :
    DataSource(parent)
{
    QDir battery("/sys/class/power_supply");
    QStringList filters;
    filters << "*battery";
    battery.setNameFilters(filters);

    const QStringList files = battery.entryList();
    QStringListIterator iterator(files);
    QString fileName;
    if ( iterator.hasNext() ) {
        fileName = battery.absoluteFilePath(iterator.next());
        qDebug() << "Found battery root: " << fileName;
    }
    m_batteryFull = registerSystemSource(fileName + "/charge_full");
    m_batteryNow = registerSystemSource(fileName + "/charge_now");
    m_capacity = registerSystemSource(fileName + "/capacity");

    connect(parent, SIGNAL(processSystemSnapshot()), SLOT(processSystemSnapshot()));
}
Ejemplo n.º 4
0
void langDisplay()
{	
	oslDrawImage(langSelection);
	
	oslIntraFontSetStyle(Roboto, 0.7f, WHITE, 0, INTRAFONT_ALIGN_LEFT);
	oslDrawStringf(20, 85, "CyanogenPSP");
	oslIntraFontSetStyle(Roboto, 0.65f, WHITE, 0, INTRAFONT_ALIGN_LEFT);
	oslDrawStringf(20, 110, "%s", lang_welcome[language][0]);
	
	oslIntraFontSetStyle(Roboto, 0.5f, WHITE, 0, INTRAFONT_ALIGN_LEFT);
	digitaltime(420,4,0,hrTime);
	battery(370,2,1);		
	
	oslDrawFillRect(60, 179, 420, 180, LITEGRAY);
	oslDrawFillRect(60, 217, 420, 218, LITEGRAY);

	for(i = curScroll; i < MAX_LANG_DISPLAY + curScroll; i++) 
	{
		if ((folderIcons[i].active == 0) && (current >= i-1)) 
		{
			current = i-1;
			break;
		}

		if (current <= curScroll-1) 
		{
			current = curScroll-1;
			break;
		}

		if (folderIcons[i].active == 1) 
		{
			oslIntraFontSetStyle(Roboto, 0.55f, BLACK, 0, INTRAFONT_ALIGN_CENTER);
			oslDrawStringf(LANG_DISPLAY_X, (i - curScroll)*36 + LANG_DISPLAY_Y, "%.56s", folderIcons[i].name);	
		}
	}
}
Ejemplo n.º 5
0
void mp3FileDisplay()
{
	oslIntraFontSetStyle(Roboto, fontSize, BLACK, 0, 0);

	oslDrawImageXY(mp3bg, 0, 0);
	oslDrawImageXY(mp3_select,8,(current - curScroll)*55+MP3_CURR_DISPLAY_Y);
	
	// Displays the directories, while also incorporating the scrolling
	for(i=curScroll;i<MAX_MP3_DISPLAY+curScroll;i++) 
	{
		// Handles the cursor and the display to not move past the MAX_MP3_DISPLAY.
		// For moving down
		//if ((folderIcons[i].active == 0) && (current >= i-1)) {
	
		if ((folderIcons[i].active == 0) && (current >= i-1)) 
		{
			current = i-1;
			break;
		}
		// For moving up
		if (current <= curScroll-1) 
		{
			current = curScroll-1;
			break;
		}
		
		// If the currently selected item is active, then display the name
		if (folderIcons[i].active == 1)
		{	
			oslDrawStringf(MP3_DISPLAY_X, (i - curScroll)*55+MP3_DISPLAY_Y, "%.62s", folderIcons[i].name);	// change the X & Y value accordingly if you want to move it (for Y, just change the +10)		
		}
	}

	battery(370,2,1);
	digitaltime(420,4,0,hrTime);
}
Ejemplo n.º 6
0
int soundPlay(char * path)
{	
	nowplaying = oslLoadImageFilePNG(nowplayingBgPath, OSL_IN_RAM, OSL_PF_8888);
	mp3Play = oslLoadImageFilePNG("system/app/apollo/play.png", OSL_IN_RAM, OSL_PF_8888);
	mp3Pause = oslLoadImageFilePNG("system/app/apollo/pause.png", OSL_IN_RAM, OSL_PF_8888);
	
	OSL_SOUND * sound = oslLoadSoundFile(path, OSL_FMT_NONE);

	if (!nowplaying)
		debugDisplay();
	
	oslInitAudioME(3);
	
	oslPlaySound(sound,0);
	
	isPlaying = 1;
	
	int Play = 1;
	
	while (!osl_quit)
	{
		LowMemExit();
		
		oslStartDrawing();		
		
		oslClearScreen(RGB(0,0,0));

		oslReadKeys();
		
		oslIntraFontSetStyle(Roboto, fontSize, BLACK, 0, 0);
		
		oslDrawImageXY(nowplaying, 0, 0);
		
		if (Play == 1)
			oslDrawImageXY(mp3Play, 230, 224);
		else if (Play == 0)
			oslDrawImageXY(mp3Pause, 230, 224);
		
		oslDrawStringf(240,76, "%.28s", folderIcons[current].name);
		
		battery(370,2,1);
		digitaltime(420,4,0,hrTime);
		volumeController();
		
		if(osl_keys->pressed.select) 
		{
			oslDeleteImage(nowplaying);
			oslDeleteImage(mp3Play);
			oslDeleteImage(mp3Pause);
			return 1;
		}
		
		if(osl_keys->pressed.cross && Play == 1) 
		{
			Play = 0;
			oslPlaySound(KeypressStandard, 1); 
			oslPauseSound(sound,-1);
		}
		else if(osl_keys->pressed.cross && Play == 0) 
		{
			Play = 1;
			oslPlaySound(KeypressStandard, 1); 
			oslPauseSound(sound,-1);
		}
		
		if(osl_keys->pressed.circle)
		{
			isPlaying = 0;
			oslStopSound(sound);
			oslDeleteSound(sound);
			oslDeleteImage(nowplaying);
			oslDeleteImage(mp3Play);
			oslDeleteImage(mp3Pause);
			return 1;
		}
		
		if (osl_keys->pressed.square)
		{
			powermenu();
		}
		
		if (osl_keys->pressed.L)
		{
			oslPlaySound(Lock, 1);  
			lockscreen();
		}
	
		captureScreenshot();
		
		oslEndDrawing(); 
        oslEndFrame(); 
		oslSyncFrame();	
		}
	oslStopSound(sound);
	oslDeleteSound(sound);
	oslDeleteImage(nowplaying);
	oslDeleteImage(mp3Play);
	oslDeleteImage(mp3Pause);
	return 0;
}
Ejemplo n.º 7
0
void newMessage()
{	
	new_message = oslLoadImageFilePNG("system/app/messenger/new_message.png", OSL_IN_RAM, OSL_PF_8888);
	
	if (!new_message)
		debugDisplay();
	
	while (!osl_quit)
	{
		LowMemExit();
		
		oslStartDrawing();
		
		oslClearScreen(RGB(0,0,0));
		
		controls();	

		oslDrawImageXY(new_message, 0, 0);
		
		navbarButtons(2);
		battery(330,2,0);
		digitaltime(381,4,0,hrTime);
		androidQuickSettings();
		volumeController();
		oslDrawImage(cursor);
		
		if (osl_keys->pressed.L)
		{
			oslPlaySound(Lock, 1);  
			lockscreen();
		}
		
		if (osl_keys->pressed.circle)
		{
			oslDeleteImage(new_message);
			messenger();
		}

		if ((cursor->x  >= 444 && cursor->x  <= 480) && (cursor->y >= 157 && cursor->y <= 213) && (osl_keys->pressed.cross))
		{
			oslPlaySound(KeypressStandard, 1);  
			oslDeleteImage(messengerbg);
			messenger();
		}

		if ((cursor->x  >= 444 && cursor->x  <= 480) && (cursor->y >= 76 && cursor->y <= 155) && (osl_keys->pressed.cross))
		{
			oslPlaySound(KeypressStandard, 1);  
			oslDeleteImage(messengerbg);
			home();
		}
		
		if ((cursor->x  >= 444 && cursor->x  <= 480) && (cursor->y >= 19 && cursor->y <= 75) && (osl_keys->pressed.cross))
		{
			oslPlaySound(KeypressStandard, 1);  
			multitask();
		}
		
		captureScreenshot();
		
		if (cursor->x >= 7 && cursor->x <= 435 && cursor->y >= 55 && cursor->y <= 86 && osl_keys->pressed.cross)
		{
			oslPlaySound(KeypressStandard, 1);  
			doServer();
		}
		
		oslIntraFontSetStyle(Roboto, fontSize, BLACK, 0, INTRAFONT_ALIGN_LEFT);
		oslDrawString(14, 245, tempMessage);
		
		if (cursor->x >= 10 && cursor->x <= 362 && cursor->y >= 228 && cursor->y <= 270 && osl_keys->pressed.cross)
		{
			oslPlaySound(KeypressStandard, 1);  
			openOSK("Enter Message", "", 128, -1);
		}
		
		if ((cursor->x >= 10 && cursor->x <= 405 && cursor->y >= 88 && cursor->y <= 118 && osl_keys->pressed.cross) && oslIsWlanPowerOn())
			doClient();
        else if ((cursor->x >= 410 && cursor->x <= 442 && cursor->y >= 92 && cursor->y <= 118 && osl_keys->pressed.cross) && oslIsWlanPowerOn())
			doServer();
		
        oslEndDrawing(); 
		oslEndFrame(); 
        oslSyncFrame();
	}
}
Ejemplo n.º 8
0
int messenger()
{	
	messengerbg = oslLoadImageFilePNG("system/app/messenger/messengerbg.png", OSL_IN_RAM, OSL_PF_8888);
	
	if (!messengerbg)
		debugDisplay();
	
	oslSetFont(Roboto);
		
	while (!osl_quit)
	{
		LowMemExit();

		oslStartDrawing();	
		
		oslClearScreen(RGB(0,0,0));
		
		oslIntraFontSetStyle(Roboto, fontSize, BLACK, 0, INTRAFONT_ALIGN_LEFT);
		
		controls();	

		oslDrawImageXY(messengerbg, 0, 0);

		navbarButtons(2);
		battery(330,2,0);
		digitaltime(381,4,0,hrTime);
		androidQuickSettings();
		volumeController();
		oslDrawImage(cursor);
		
		if (osl_keys->pressed.square)
		{
			powermenu();
		}
		
		if (osl_keys->pressed.L)
		{
			oslPlaySound(Lock, 1);  
			lockscreen();
		}
		
		if (osl_keys->pressed.circle)
		{
			oslDeleteImage(messengerbg);
			appdrawer();
		}
	
		if ((cursor->x  >= 444 && cursor->x  <= 480) && (cursor->y >= 157 && cursor->y <= 213) && (osl_keys->pressed.cross))
		{
			oslPlaySound(KeypressStandard, 1);  
			oslDeleteImage(messengerbg);
			appdrawer();
		}

		if ((cursor->x  >= 444 && cursor->x  <= 480) && (cursor->y >= 76 && cursor->y <= 155) && (osl_keys->pressed.cross))
		{
			oslPlaySound(KeypressStandard, 1);  
			oslDeleteImage(messengerbg);
			home();
		}
		
		if ((cursor->x  >= 444 && cursor->x  <= 480) && (cursor->y >= 19 && cursor->y <= 75) && (osl_keys->pressed.cross))
		{
			oslPlaySound(KeypressStandard, 1);  
			multitask();
		}
		
		captureScreenshot();
		
		if (cursor->x >= 385 && cursor->x <= 428 && cursor->y >= 210 && cursor->y <= 258 && osl_keys->pressed.cross)
		{
			oslPlaySound(KeypressStandard, 1);  
			oslDeleteImage(messengerbg);
			newMessage();
		}
		
		/*
		if (cursor->x >= 378 && cursor->x <= 434 && cursor->y >= 20 && cursor->y <= 52 && osl_keys->pressed.cross)
		{
			oslPlaySound(KeypressStandard, 1);  
			oslDeleteImage(messengerbg);
			doClient();
		}
		*/
		
		oslEndDrawing(); 
		oslEndFrame(); 
		oslSyncFrame();
	}
	return 0;
}
Ejemplo n.º 9
0
void powermenu()
{	
	power = oslLoadImageFilePNG("system/home/menu/powerMenu.png", OSL_IN_RAM, OSL_PF_8888);
	powerSelection = oslLoadImageFilePNG("system/home/menu/powerSelection.png", OSL_IN_RAM, OSL_PF_8888);
	recoverySelection = oslLoadImageFilePNG("system/home/menu/recoverySelection.png", OSL_IN_RAM, OSL_PF_8888);
	
	if (!power || !powerSelection || !recoverySelection)
		debugDisplay();

	while (!osl_quit)
	{
		LowMemExit();
	
		oslStartDrawing();

		controls();	

		oslClearScreen(RGB(0,0,0));	
		oslDrawImage(background);
		oslDrawImageXY(ic_launcher_apollo, 105, 190);
		oslDrawImageXY(ic_launcher_browser, 276, 190);
		oslDrawImageXY(ic_launcher_settings, 331, 190);
		oslDrawImageXY(ic_launcher_messenger, 160, 190);
		navbarButtons(0);
		oslDrawImageXY(power, 100, 61);
		
		battery(370,2,1);
		digitaltime(420,4,0,hrTime);
		
		oslIntraFontSetStyle(Roboto, 0.75f, BLACK, 0, 0);
		oslDrawStringf(165, 100, "Power off");
		oslDrawStringf(165, 165, "Recovery");
		
		if (cursor->x >= 116 && cursor->x <= 364 && cursor->y >= 55 && cursor->y <= 125) 
		{
			oslDrawImageXY(powerSelection, 100, 60);
			oslDrawStringf(165, 100, "Power off");
			oslDrawStringf(165, 165, "Recovery");
			
			if (osl_keys->pressed.cross)
			{	
				oslPlaySound(KeypressStandard, 1);  
				sceKernelExitGame();
			}
			/*else if (osl_pad.held.cross)
			{
				scePowerRequestColdReset(0);
				scePowerRequestColdReset(50000);
			}*/
		}
		if (cursor->x >= 116 && cursor->x <= 364 && cursor->y >= 126 && cursor->y <= 200) 
		{
			oslDrawImageXY(recoverySelection, 100, 60);
			oslDrawStringf(165, 100, "Power off");
			oslDrawStringf(165, 165, "Recovery");
			if (osl_keys->pressed.cross)
			{	
				oslPlaySound(KeypressStandard, 1);  
				oslSyncFrame();
				sceKernelDelayThread(3*1000000);
				oslDeleteImage(power);
				oslDeleteImage(powerSelection);
				oslDeleteImage(recoverySelection);
				mainRecoveryMenu();
			}
		}
		
		oslDrawImage(cursor);
	
		if (osl_keys->pressed.circle)
		{	
			oslDeleteImage(power);
			oslDeleteImage(powerSelection);
			oslDeleteImage(recoverySelection);
			return;
		}
		
		captureScreenshot();
		
		oslEndDrawing(); 
		oslEndFrame(); 
		oslSyncFrame();
	}
}
Ejemplo n.º 10
0
int main(void) {

  InitPeripherals();
  mRedOFF; mGreenOFF; mBlueOFF;

  // startup blink
  const float kShortDelay = 0.1;
  const float kLongDelay = 0.3;
  mRedON; mGreenON; mBlueON;
  DelaySeconds(kShortDelay);
  mRedOFF; mGreenOFF; mBlueOFF;
  DelaySeconds(kLongDelay);
  mRedON; mGreenON; mBlueON;
  DelaySeconds(kShortDelay);
  mRedOFF; mGreenOFF; mBlueOFF;
  DelaySeconds(kLongDelay);
  mRedON; mGreenON; mBlueON;
  DelaySeconds(kShortDelay);
  mRedOFF; mGreenOFF; mBlueOFF;
  DelaySeconds(kLongDelay);

  UsbInterface usb = UsbInterface();
  usb.Init();

  PersistentMemory mem;

  DelaySeconds(1.0f);
  ZigbeeInterface zig = ZigbeeInterface();
  DelaySeconds(0.05f);
  zig.Init(mem);

  error_reporting_com1 = &usb;
  error_reporting_com2 = &zig;

  Mpu60XXImu imu(mem);
  GyroAccelDriftUkfIo est;

  BatteryMonitor battery(mem);
  battery_ptr = &battery;

  MotorHal motor_hal(mem);
  motor_hal_ptr = &motor_hal;

  // Get_pos addition:
  InitPositionSensor();
  tim1_set_position_callback_2(get_position);
  QuatPD pd(mem);
  PulsingCoaxControllerQuat uav(mem, pd, imu, est, motor_hal);

  CoaxOpenController open_controller(mem);
  CoaxOpenAttitudeController open_attitude_controller(mem, est);

  monitor = LoopMonitor(mem);
  UavReporter reporter(mem, imu, est, motor_hal, battery, uav, open_attitude_controller, pd, monitor);
  StateMachine state_machine;

  mem.Freeze();  // freeze memory to make writes possible

  imu.InitFromMemory();
  //imu.DefaultAccelSensitivity(1); // overwrite scale for off-datasheet fix
  imu.flip_z = 1;                   // flip z-axis direction for upside-down imu

  #ifdef STREAM_IMU_RAW
    imu_raw_msg_logger_init(imu);
  #endif

  monitor.InitFromMemory();

  PlayTimebase();
  imu.StartRead();
  DelayMilliseconds(10);

  tim1_init();
  tim1_set_supply_volts(3.7f);

  //////////////////////////////////////////////////////////////////////////////
  // Main Loop
  while(1) {
                                                                                monitor.Profile(0);
    ////////////////////////////////////////////////////////////////////////////
    // Get IMU Data and Start New Measurement
    while(!imu.FinishRead()) {};
    #ifdef STREAM_IMU_RAW
      imu_raw_msg_logger_push();
    #endif
    DelayMicroseconds(50); // this seems to be critical (?!?)
    imu.StartRead();
                                                                                monitor.Profile(1);
    ////////////////////////////////////////////////////////////////////////////
    // Update Estimator with Measurement
    est.Update(imu.time, imu.w, imu.a);

    ////////////////////////////////////////////////////////////////////////////
    // Control                                                                             

    // update control laws
    uav.Update();
    open_controller.Update();
    open_attitude_controller.Update();

    // map controllers to outputs based on state
    enum control_state state = state_machine.get_state();

    // in STOP state, send active kill messages to motors
    if(state == kStop) {
      mGreenOFF; mAmberON;
      motor_hal.set_top_cmd_volts(0);
      motor_hal.set_top_cmd_volts_pulse_amp(0);
      motor_hal.set_top_cmd_pulse_phase(0);
      motor_hal.set_bottom_cmd_volts(0);
    }

    // in STANDBY state, send no motor commands except on entry
    else if(state == kStandby) {
      mGreenOFF; mAmberOFF;
      if(state_machine.get_standby_needs_init()) {
        motor_hal.set_top_cmd_volts(0);
        motor_hal.set_top_cmd_volts_pulse_amp(0);
        motor_hal.set_top_cmd_pulse_phase(0);
        motor_hal.set_bottom_cmd_volts(0);
        state_machine.clear_standby_needs_init();
      }
    }

    // in QUAT state, send motor commands according to quat control law
    else if(state == kQuat) {
      mGreenON; mAmberOFF;
      motor_hal.set_top_cmd_volts(uav.top_mean);
      motor_hal.set_top_cmd_volts_pulse_amp(uav.top_pulse_amp);
      motor_hal.set_top_cmd_pulse_phase(uav.top_pulse_phase);
      motor_hal.set_bottom_cmd_volts(uav.bottom_mean);
    }

    // in OPEN state, send motor command according to open motor control commands
    else if(state == kOpen) {
      mGreenON; mAmberOFF;
      motor_hal.set_top_cmd_volts(open_controller.top_mean);
      motor_hal.set_top_cmd_volts_pulse_amp(open_controller.top_pulse_amp);
      motor_hal.set_top_cmd_pulse_phase(open_controller.top_pulse_phase);
      motor_hal.set_bottom_cmd_volts(open_controller.bottom_mean);
    }

    // in OPEN ATTITUDE state, send motor command according to open motor control commands
    else if(state == kOpenAttitude) {
      mGreenON; mAmberOFF;
      motor_hal.set_top_cmd_volts(open_attitude_controller.top_mean);
      motor_hal.set_top_cmd_volts_pulse_amp(open_attitude_controller.top_pulse_amp);
      motor_hal.set_top_cmd_pulse_phase(open_attitude_controller.top_pulse_phase);
      motor_hal.set_bottom_cmd_volts(open_attitude_controller.bottom_mean);
    }
                                                                                monitor.Profile(2);
    ////////////////////////////////////////////////////////////////////////////
    // Packet Communication
    uint8_t is_data;    // 1 iff data received
    uint8_t *rx_data;   // temporary pointer to received type+data bytes
    uint8_t rx_length;  // number of received type+data bytes

    ////////////////////////////////////////////////////////////////////////////
    // USB Input
    is_data = 0;
    usb.GetBytes();
    while(usb.PeekPacket(&rx_data, &rx_length)) {
      zig.ReadMsg(usb, rx_data, rx_length);
      imu.ReadMsg(usb, rx_data, rx_length);
      est.ReadMsg(usb, rx_data, rx_length);
      mem.ReadMsg(usb, rx_data, rx_length);
      uav.ReadMsg(usb, rx_data, rx_length);
      open_controller.ReadMsg(          usb, rx_data, rx_length);
      open_attitude_controller.ReadMsg( usb, rx_data, rx_length);
      pd.ReadMsg(       usb, rx_data, rx_length);
      monitor.ReadMsg(  usb, rx_data, rx_length);
      motor_hal.ReadMsg(usb, rx_data, rx_length);
      battery.ReadMsg(  usb, rx_data, rx_length);
      reporter.ReadMsg( usb, rx_data, rx_length);
      state_machine.ReadMsg(usb, rx_data, rx_length);
      usb.DropPacket();
      is_data = 1;
    } // while peek...
    if(is_data) {
      usb.SendNow();
    }

    ////////////////////////////////////////////////////////////////////////////
    // Radio Input
    is_data = 0;
    zig.GetBytes();
    while(zig.PeekPacket(&rx_data, &rx_length)) {
      #ifdef STREAM_IMU_RAW
        if(rx_data[0] == kTypeQuatPilot || rx_data[0] == kTypeQuatFullObsPilot || rx_data[0] == kTypeOpenPilot || rx_data[0] == kTypeOpenAttitudePilot) {
          imu_raw_msg_logger_send(zig);
        }
      #endif

      zig.ReadMsg(zig, rx_data, rx_length);
      imu.ReadMsg(zig, rx_data, rx_length);
      est.ReadMsg(zig, rx_data, rx_length);
      mem.ReadMsg(zig, rx_data, rx_length);
      uav.ReadMsg(zig, rx_data, rx_length);
      open_controller.ReadMsg(          zig, rx_data, rx_length);
      open_attitude_controller.ReadMsg( zig, rx_data, rx_length);
      pd.ReadMsg(       zig, rx_data, rx_length);
      monitor.ReadMsg(  zig, rx_data, rx_length);
      motor_hal.ReadMsg(zig, rx_data, rx_length);
      battery.ReadMsg(  zig, rx_data, rx_length);
      reporter.ReadMsg( zig, rx_data, rx_length);
      state_machine.ReadMsg(zig, rx_data, rx_length);
      zig.DropPacket();
      is_data = 1;
    } // while peek...
                                                                                monitor.Profile(3);
    if(is_data) {
      zig.SendNow();
    }
                                                                                monitor.Profile(4);
                                                                                monitor.Profile(5);
    ////////////////////////////////////////////////////////////////////////////    
    // Throttle main loop to main_freq
    monitor.EndMainLoop();
                                                                                monitor.Profile(6);
                                                                                //monitor.SendProfile(usb);
                                                                                //usb.SendNow();
  } // while(1)
  return(0);
}
Ejemplo n.º 11
0
int appdrawer()
{	
	int browser_x = 30;
	int browser_text_x = 52;
	int calc_x = 105;
	int calc_text_x = 127;
	int clock_x = 180;
	int clock_text_x = 202;
	int fm_x = 255;
	int fm_text_x = 277;
	int gallery_x = 330;
	int gallery_text_x = 352;
	int game_icon = 405;
	int game_text_icon = 427;
	int messenger_x = 30;
	int messenger_text_x = 52; 
	int music_x = 105;
	int music_text_x = 127;
	int settings_x = 180;
	int settings_test_x = 202;
	int umd_x = 255;
	int umd_text_x = 277;

	//loads appdrawer icons
	appdrawer_loadImages();
	
	if (!ic_launcher_clock || !backdrop)
		debugDisplay();

	oslSetFont(Roboto);
		
	while (!osl_quit)
	{
		LowMemExit();
		
		oslStartDrawing();

		controls();	
		
		oslDrawImage(background);
		
		if (eDesktopActivator == 1)
		{
			navbarButtons(1);
			battery(370,2,3);
			if ((cursor->y <= 16) || (cursor->y >= 226))
			{
				digitaltime(420,4,0,hrTime);
			}
			else if (cursor->y >= 16 && cursor->y <= 226)
			{
				digitaltime(420,-10,0,hrTime);
			}	
		}
		else if (eDesktopActivator == 0)
		{
			navbarButtons(0);
			battery(370,2,1);
			digitaltime(420,4,0,hrTime);
		}
		
		if (DARK == 0)
			oslIntraFontSetStyle(Roboto, fontSize, BLACK, 0, INTRAFONT_ALIGN_CENTER);
		else
			oslIntraFontSetStyle(Roboto, fontSize, WHITE, 0, INTRAFONT_ALIGN_CENTER);
			
		oslDrawImageXY(backdrop, 1, 15);
		oslDrawImageXY(ic_launcher_browser, browser_x, 40);
		oslDrawStringf(browser_text_x, 90, "%s", lang_appDrawer[language][0]);
		oslDrawImageXY(ic_launcher_calculator, calc_x, 40);
		oslDrawStringf(calc_text_x, 90, "%s", lang_appDrawer[language][1]);
		oslDrawImageXY(ic_launcher_clock, clock_x, 40);
		oslDrawStringf(clock_text_x, 90, "%s", lang_appDrawer[language][2]);
		oslDrawImageXY(ic_launcher_filemanager, fm_x, 40);
		oslDrawStringf(fm_text_x, 90,"%s", lang_appDrawer[language][3]);
		oslDrawImageXY(ic_launcher_gallery, gallery_x, 40);
		oslDrawStringf(gallery_text_x, 90, "%s", lang_appDrawer[language][4]);
		oslDrawImageXY(ic_launcher_game, game_icon, 40);
		oslDrawStringf(game_text_icon, 90, "%s", lang_appDrawer[language][5]);
		oslDrawImageXY(ic_launcher_messenger, messenger_x, 130);
		oslDrawStringf(messenger_text_x, 185, "%s", lang_appDrawer[language][6]);
		oslDrawImageXY(ic_launcher_apollo, music_x, 130);
		oslDrawStringf(music_text_x, 185, "%s", lang_appDrawer[language][7]);
		oslDrawImageXY(ic_launcher_settings, settings_x, 130);
		oslDrawStringf(settings_test_x, 185, "%s", lang_appDrawer[language][8]);
		oslDrawImageXY(ic_launcher_umd, umd_x, 132);
		oslDrawStringf(umd_text_x, 185, "%s", lang_appDrawer[language][9]);

		androidQuickSettings();
		volumeController();
		appHighlight(1);
		oslDrawImage(cursor);
		
		if (osl_keys->pressed.square)
		{ 
			powermenu();
		}
		
		if (osl_keys->pressed.L)
		{
			oslPlaySound(Lock, 1);  
			lockscreen();
        }
		
		if (osl_keys->pressed.circle)
		{
			appdrawer_deleteImages();
			home();
		}
		
		if (cursor->x >= 15 && cursor->x <= 75 && cursor->y >= 25 && cursor->y <= 85 && osl_keys->pressed.cross)
		{
			oslPlaySound(KeypressStandard, 1); 
			appdrawer_deleteImages();
			internet();
		}
		
		if (experimentalF == 1)
		{	// WIP calculator
			if (cursor->x >= 100 && cursor->x <= 140 && cursor->y >= 25 && cursor->y <= 85 && osl_keys->pressed.cross)
			{
				oslPlaySound(KeypressStandard, 1); 
				appdrawer_deleteImages();
				calculator();
			}
		}
		
		if (cursor->x >= 160 && cursor->x <= 225 && cursor->y >= 25 && cursor->y <= 85 && osl_keys->pressed.cross)
		{
			oslPlaySound(KeypressStandard, 1); 
			appdrawer_deleteImages();
			pspclock();
		}
		
		if (cursor->x >= 245 && cursor->x <= 295 && cursor->y >= 25 && cursor->y <= 85 && osl_keys->pressed.cross)
		{
			oslPlaySound(KeypressStandard, 1);  
			appdrawer_deleteImages();
			filemanage();
		}
		
		if (cursor->x >= 320 && cursor->x <= 370 && cursor->y >= 25 && cursor->y <= 85 && osl_keys->pressed.cross)
		{
			oslPlaySound(KeypressStandard, 1); 
			appdrawer_deleteImages();
			galleryApp();
		}
		
		if (cursor->x >= 390 && cursor->x <= 450 && cursor->y >= 25 && cursor->y <= 85 && osl_keys->pressed.cross)
		{
			oslPlaySound(KeypressStandard, 1); 
			appdrawer_deleteImages();
			gameApp();
		}

		if (experimentalF == 1)
		{	//WIP ad-hoc messenger application
			if (cursor->x >= 15 && cursor->x <= 75 && cursor->y >= 115 && cursor->y <= 180 && osl_keys->pressed.cross)
			{
				oslPlaySound(KeypressStandard, 1); 
				appdrawer_deleteImages();
				messenger();
			}
		}
		
		if (cursor->x >= 100 && cursor->x <= 140 && cursor->y >= 115 && cursor->y <= 180 && osl_keys->pressed.cross)
		{
			oslPlaySound(KeypressStandard, 1); 
			appdrawer_deleteImages();
			mp3player();
		}
		
		if (cursor->x >= 160 && cursor->x <= 225 && cursor->y >= 115 && cursor->y <= 180 && osl_keys->pressed.cross)
		{
			oslPlaySound(KeypressStandard, 1); 
			appdrawer_deleteImages();
			settingsMenu();
		}
		
		if (cursor->x >= 245 && cursor->x <= 295 && cursor->y >= 115 && cursor->y <= 180 && osl_keys->pressed.cross)
		{
			oslPlaySound(KeypressStandard, 1); 
			launchUMD("disc0:/PSP_GAME/SYSDIR/EBOOT.BIN");
		}
		
		if (cursor->x >= 137 && cursor->x <= 200 && cursor->y >= 237 && cursor->y <= 271 && osl_keys->pressed.cross)
		{
			oslPlaySound(KeypressStandard, 1); 
			appdrawer_deleteImages();
			home();
		}
		
		if (cursor->x >= 200 && cursor->x <= 276 && cursor->y >= 237 && cursor->y <= 271 && osl_keys->pressed.cross)
		{
			oslPlaySound(KeypressStandard, 1); 
			appdrawer_deleteImages();
			home();
		}
		
		if (cursor->x >= 276 && cursor->x <= 340 && cursor->y >= 237 && cursor->y <= 271 && osl_keys->pressed.cross)
		{
			oslPlaySound(KeypressStandard, 1); 
			multitask();
		}
		
		captureScreenshot();
				
		oslEndDrawing(); 
        oslEndFrame(); 
		oslSyncFrame();	
	}
	return 0;
}
Ejemplo n.º 12
0
/* Construct Packet */
void Construct_Packet(void)
{
  //Serial.println("construct packet top");

  //Variable for Index and uptime
  unsigned long uptime_ms;

  //Put schema number in packet
  G_packet.schema = 297;

  //Update data
  uptime_ms = millis();

  //Put uptime in packet
  G_packet.uptime_ms = uptime_ms;

  //Poll and put battery and panel data in packet
  for(int p = 0; p < 6; p++)
  { G_packet.batt_mv[p] = battery();
    G_packet.panel_mv[p] = panel();
    delay(400);
  }
  
  //Poll and put panel data in packet
  /*for(int p = 0; p < 6; p++)
  { G_packet.panel_mv[p] = panel();
    delay(400);
  }*/
  
  G_packet.bmp185_press_pa = pressure();
  G_packet.bmp185_temp_decic = temp();
  G_packet.humidity_centi_pct = humidity();

  //Poll and put irradiance data in packet
  for(int i = 0; i < 20; i++)
  { G_packet.solar_irr_w_m2[i] = irradiance();
    delay(300);
  }
  
  /*//Hardcoded Test Packet
  G_packet.uptime_ms = 1;
  for(int p = 0; p <= 4; p++)
  { G_packet.batt_mv[p] = 1;
    Serial.print("Battery");
    Serial.println(G_packet.batt_mv[p]);
    delay(400);
  }
  for(int p = 0; p <= 4; p++)
  { G_packet.panel_mv[p] = 2;
    Serial.print("Panel");
    Serial.println(G_packet.panel_mv[p]);
    delay(400);
  }
  
  G_packet.bmp185_press_pa = 3;
  Serial.print("Pressure");
  Serial.println(G_packet.bmp185_press_pa);
  G_packet.bmp185_temp_decic = 4;
  Serial.print("Temp");
  Serial.println(G_packet.bmp185_temp_decic);
  G_packet.humidity_centi_pct = 5;
  Serial.print("Humidity");
  Serial.println(G_packet.humidity_centi_pct);
  for(int i = 0; i <= 14; i++)
  { G_packet.solar_irr_w_m2[i] = 6;
    Serial.print("Solar");
    Serial.println(G_packet.solar_irr_w_m2[i]);
    delay(1000);
  }*/
}
Ejemplo n.º 13
0
int mp3player() 
{
	mp3bg = oslLoadImageFilePNG(apolloBgPath, OSL_IN_RAM, OSL_PF_8888);
	mp3_select = oslLoadImageFilePNG(apolloSelectorPath, OSL_IN_RAM, OSL_PF_8888);
	
	if (!mp3bg || !mp3_select)
		debugDisplay();

	oslSetFont(Roboto);
	
	int MenuSelection = 1; // Pretty obvious
	int selector_x = 8; //The x position of the first selection
	int selector_y = 43; //The y position of the first selection
	int selector_image_x; //Determines the starting x position of the selection
	int selector_image_y = 55; //Determines the starting y position of the selection
	int numMenuItems = 3; //Amount of items in the menu
	int selection = 0;

	while (!osl_quit)
	{		
		LowMemExit();
		
		selector_image_x = selector_x+(mp3XSelection*MenuSelection); //Determines where the selection image is drawn for each selection
        selector_image_y = selector_y+(mp3YSelection*MenuSelection); //Determines where the selection image is drawn for each selection
	
		oslStartDrawing();
		oslReadKeys();
		oslClearScreen(RGB(0,0,0));	
		
		oslIntraFontSetStyle(Roboto, fontSize, BLACK, 0, 0);
		
		oslDrawImageXY(mp3bg, 0, 0);
		oslDrawImageXY(mp3_select, selector_image_x, selector_image_y);
		
		oslDrawStringf(20,108,"MUSIC");
		oslDrawStringf(20,163,"PSP/MUSIC");
		oslDrawStringf(20,218,"PSP/GAME/CyanogenPSP/Downloads");
		
		battery(370,2,1);
		digitaltime(420,4,0,hrTime);
		volumeController();
		
        if (osl_keys->pressed.down) MenuSelection++; //Moves the selector down
        if (osl_keys->pressed.up) MenuSelection--; //Moves the selector up
        
        if (MenuSelection > numMenuItems) MenuSelection = 1; //Sets the selection to the first
        if (MenuSelection < 1) MenuSelection = numMenuItems; //Sets the selection back to last
		
		if (MenuSelection == 1 && osl_keys->pressed.cross)
        {	
			oslPlaySound(KeypressStandard, 1);  
			oslDeleteImage(mp3bg);
			oslDeleteImage(mp3_select);
			mp3View("ms0:/MUSIC");
        }
		else if (MenuSelection == 2 && osl_keys->pressed.cross)
        {		
			oslPlaySound(KeypressStandard, 1);  
			oslDeleteImage(mp3bg);
			oslDeleteImage(mp3_select);
			mp3View("ms0:/PSP/MUSIC");
        }
		else if (MenuSelection == 3 && osl_keys->pressed.cross)
        {	
			oslPlaySound(KeypressStandard, 1);  
			oslDeleteImage(mp3bg);
			oslDeleteImage(mp3_select);
			mp3View("ms0:/PSP/GAME/CyanogenPSP/downloads");
        }
		
		if (osl_keys->pressed.circle)
		{
			oslDeleteImage(mp3bg);
			oslDeleteImage(mp3_select);
			appdrawer();
		}
		
		if (osl_keys->pressed.square)
		{
			powermenu();
		}
		
		if (osl_keys->pressed.L)
		{
			oslPlaySound(Lock, 1);  
			lockscreen();
		}
	
		captureScreenshot();
		
		oslEndDrawing(); 
        oslEndFrame(); 
		oslSyncFrame();	
	}	
	return selection;
}
Ejemplo n.º 14
0
//First Boot Message
void firstBootInitiation()
{	
	firstBoot = setFileDefaultsInt("system/settings/boot.bin", 1, firstBoot);

	iconPackLoad();

	//Loads our images into memory
	loadIcons();
	background = oslLoadImageFile(backgroundPath, OSL_IN_RAM, OSL_PF_8888);
	cursor = oslLoadImageFilePNG(cursorPath, OSL_IN_VRAM, OSL_PF_8888);
	navbar = oslLoadImageFile(navbarPath, OSL_IN_RAM, OSL_PF_8888);
	navbar2 = oslLoadImageFile(navbar2Path, OSL_IN_RAM, OSL_PF_8888);
	//notif = oslLoadImageFile("system/home/menu/notif.png", OSL_IN_RAM, OSL_PF_8888);
	welcome = oslLoadImageFilePNG("system/home/icons/welcome.png", OSL_IN_RAM, OSL_PF_8888);
	transbackground = oslLoadImageFilePNG("system/home/icons/transbackground.png", OSL_IN_RAM, OSL_PF_8888);
	control = oslLoadImageFilePNG("system/home/menu/brightnesscontrol.png", OSL_IN_VRAM, OSL_PF_8888);
	ic_launcher_apollo = oslLoadImageFilePNG(apolloPath, OSL_IN_RAM, OSL_PF_8888);
	ic_launcher_browser = oslLoadImageFile(browserPath, OSL_IN_RAM, OSL_PF_8888);
	ic_launcher_calculator = oslLoadImageFilePNG(calcPath, OSL_IN_RAM, OSL_PF_8888);
	ic_launcher_filemanager = oslLoadImageFilePNG(fmPath, OSL_IN_RAM, OSL_PF_8888);
	ic_launcher_gallery = oslLoadImageFilePNG(galleryPath, OSL_IN_RAM, OSL_PF_8888);
	ic_launcher_game = oslLoadImageFilePNG(gamePath, OSL_IN_RAM, OSL_PF_8888);
	ic_launcher_messenger = oslLoadImageFilePNG(messagesPath, OSL_IN_RAM, OSL_PF_8888);
	ic_launcher_settings = oslLoadImageFilePNG(settingsPath, OSL_IN_RAM, OSL_PF_8888);
	ic_launcher_umd = oslLoadImageFilePNG(umdPath, OSL_IN_RAM, OSL_PF_8888);
	usbdebug = oslLoadImageFilePNG("system/home/icons/usbdebug.png", OSL_IN_RAM, OSL_PF_8888);
	music = oslLoadImageFilePNG("system/home/icons/music.png", OSL_IN_RAM, OSL_PF_8888);
	
	
	//Debugger - Displays an error message if the following resources are missing.
	if (!background || !cursor || !ic_allapps || !ic_allapps_pressed || !navbar || !ic_launcher_apollo || !ic_launcher_settings || !ic_launcher_messenger || !ic_launcher_browser || !batt100 || !batt80 || !batt60 || !batt40 || !batt20 || !batt10 || !batt0 || !battcharge || !navbar2 || !usbdebug  || !music)
		debugDisplay();
		
	//Sets the cursor's original position on the screen
	cursor->x = 240;
	cursor->y = 136;	
	
	if (firstBoot!= 0)
	{
		while (!osl_quit)
		{		
			oslStartDrawing();

			controls();

			oslDrawImage(background);		
			oslDrawImageXY(ic_launcher_apollo, 105, 190);
			oslDrawImageXY(ic_launcher_browser, 276, 190);
			oslDrawImageXY(ic_launcher_settings, 331, 190);
			oslDrawImageXY(ic_launcher_messenger, 160, 190);
			oslSetTransparentColor(RGB(0,0,0));
			appDrawerIcon();
			oslDisableTransparentColor();
		
			oslIntraFontSetStyle(Roboto, 0.5f, WHITE, 0, INTRAFONT_ALIGN_LEFT);
			
			digitaltime(420,4,0,hrTime);
			volumeController();
			battery(370,2,1);
			navbarButtons(0);
			
			oslDrawImageXY(transbackground, 0, 0);
			oslDrawImageXY(welcome, 0, 0);
			
			oslIntraFontSetStyle(Roboto, 0.8f,BLACK,0,INTRAFONT_ALIGN_LEFT);
			oslDrawStringf(20,30, "%s", lang_welcome[language][0]);
			
			oslIntraFontSetStyle(Roboto, 0.6f,DARKGRAY,0,INTRAFONT_ALIGN_LEFT);
			oslDrawStringf(20,60, "%s", lang_welcome[language][1]);
			
			oslDrawStringf(20,80, "%s", lang_welcome[language][2]);
			
			oslIntraFontSetStyle(Roboto, 0.6f,WHITE,0,INTRAFONT_ALIGN_LEFT);
			oslDrawStringf(385,110, "%s", lang_welcome[language][3]);
			
			oslDrawImage(cursor);
	
			if (cursor->x >= 388 && cursor->x <= 464 && cursor->y >= 98 && cursor->y <= 132 && osl_keys->pressed.cross)
			{
				FILE * firstBootTxt = fopen("system/settings/boot.bin", "w"); 
				fprintf(firstBootTxt, "0");
				fclose(firstBootTxt);
				oslPlaySound(KeypressStandard, 1); 
				oslDeleteImage(welcome);
				oslDeleteImage(transbackground);
				unloadIcons();
				home();
			}
			
			captureScreenshot();
			
		oslEndDrawing(); 
        oslEndFrame(); 
		oslSyncFrame();	
		}
	}
		
	if (firstBoot == 0)
	{
		oslDeleteImage(welcome);
		oslDeleteImage(transbackground);
		unloadIcons();
		lockscreen();
		home();
	}
}
Ejemplo n.º 15
0
void Bluetooth::onReadyRead(void)
{
    qDebug() << "Ready read..." << "request:" << m_request;

    if (!m_socket)
        return;

    while (m_socket->canReadLine()) {
        QByteArray data = m_socket->readLine();
        QString line = QString::fromUtf8(data.constData(), data.length()).trimmed();
        if (line.length() > 0) {
            qDebug() << "Received:" << line << "request:" << m_request;

            if (m_timer->isActive()) {
                m_timer->stop();
            }

            switch (m_request) {
                case REQUEST_BATTERY:
                    if (line.contains(BLUETOOTH_CMD_BATTERY)) {
                        line.remove(BLUETOOTH_CMD_BATTERY + QString(": "));
                        line.remove(QChar('%'));
                        unsigned int capacity = line.toInt();
                        m_request = REQUEST_NO_REQUEST;
                        emit battery(capacity);
                    } else {
                        // FIXME: ERROR
                    }
                    break;

                case REQUEST_EYES:
                    if (line.contains(BLUETOOTH_CMD_EYES)) {
                        PowerState state;
                        if (line.contains(BLUETOOTH_PARAM_ON)) {
                            state = PowerOn;
                        } else {
                            state = PowerOff;
                        }
                        m_request = REQUEST_NO_REQUEST;
                        emit eyes(state);
                    } else {
                        getEyes();
                    }
                    break;

                case REQUEST_HELMET:
                    if (line.contains(BLUETOOTH_CMD_HELMET)) {
                        HelmetState state;
                        if (line.contains(BLUETOOTH_PARAM_CLOSE)) {
                            state = HelmetClose;
                        } else {
                            state = HelmetOpen;
                        }
                        m_request = REQUEST_NO_REQUEST;
                        emit helmet(state);
                    } else {
                        getHelmet();
                    }
                    break;

                case REQUEST_INTENSITY:
                    if (line.contains(BLUETOOTH_CMD_INTENSITY)) {
                        line.remove(BLUETOOTH_CMD_INTENSITY + QString(": "));
                        PowerIntensity value = (PowerIntensity) line.toInt();
                        m_request = REQUEST_NO_REQUEST;
                        emit intensity(m_intensityDevice, value);
                    } else {
                        getIntensity(m_intensityDevice);
                    }
                    break;

                case REQUEST_QUOTE:
                    if (line.contains("OK")) {
                        m_request = REQUEST_NO_REQUEST;
                        emit quoteFinished();
                    } else {
                        // FIXME: ERROR
                    }
                    break;

                case REQUEST_REPULSOR:
                    if (line.contains("OK")) {
                        emit repulsorBlastGenerated(m_repulsor);
                    }
                    m_request = REQUEST_NO_REQUEST;
                    break;

                case REQUEST_REPULSORS:
                    if (line.contains(BLUETOOTH_CMD_REPULSORS)) {
                        PowerState state;
                        if (line.contains(BLUETOOTH_PARAM_ON)) {
                            state = PowerOn;
                        } else {
                            state = PowerOff;
                        }
                        m_request = REQUEST_NO_REQUEST;
                        emit repulsors(state);
                    } else {
                        getRepulsors();
                    }
                    break;

                case REQUEST_UNIBEAM:
                    if (line.contains(BLUETOOTH_CMD_UNIBEAM)) {
                        PowerState state;
                        if (line.contains(BLUETOOTH_PARAM_ON)) {
                            state = PowerOn;
                        } else {
                            state = PowerOff;
                        }
                        m_request = REQUEST_NO_REQUEST;
                        emit unibeam(state);
                    } else {
                        getUnibeam();
                    }
                    break;

                case REQUEST_VERSION:
                    if (m_revision.isEmpty()) {
                        m_revision = line;
                    } else if (m_build.isEmpty()) {
                        m_build = line;
                        m_request = REQUEST_NO_REQUEST;
                        emit version(m_revision, m_build);
                    }
                    break;

                case REQUEST_VOLUME:
                    if (line.contains(BLUETOOTH_CMD_VOLUME)) {
                        line.remove(BLUETOOTH_CMD_VOLUME + QString(": "));
                        VolumeLevel level = (VolumeLevel) line.toInt();
                        emit volume(level);
                        m_request = REQUEST_NO_REQUEST;
                    } else {
                        getVolume();
                    }
                    break;

                default:
                    break;
            }
        }
    }
}
Ejemplo n.º 16
0
int calculator()
{
	//int result;
	int x = 1;
	int y = 1;
	/*
	int enterednumber;
	int numberuse = 0;
	int suppression = 1;
	int Number = 0;
	*/

	calcbackground = oslLoadImageFile("system/app/calculator/calcbg.png", OSL_IN_RAM, OSL_PF_8888);

	oslSetFont(Roboto);
	
	if (!calcbackground)
		debugDisplay();
		
	while (!osl_quit)
	{
		LowMemExit();
	
		oslStartDrawing();
		
		oslClearScreen(RGB(0,0,0));
		
		controls();	

		oslDrawImageXY(calcbackground, 0, 0);
		
		battery(370,2,1);
		digitaltime(420,4,0,hrTime);
		volumeController();
		
		oslIntraFontSetStyle(Roboto, 0.8f,WHITE,0,0);

		oslDrawString(35,120,"7");
		oslDrawString(90,120,"8");
		oslDrawString(145,120,"9");
		oslDrawString(35,160,"4");
		oslDrawString(90,160,"5");
		oslDrawString(145,160,"6");
		oslDrawString(35,200,"1");
		oslDrawString(90,200,"2");
		oslDrawString(145,200,"3");
		oslDrawString(90,240,"0");

		oslDrawString(218,120,"/");
		oslDrawString(218,160,"x");
		oslDrawString(218,200,"-");
		oslDrawString(218,240,"+");
		oslIntraFontSetStyle(Roboto, 0.6f,WHITE,0,0);
		oslDrawString(260,120,"DEL");

		oslDrawString(326,120,"sin");
		oslDrawString(366,120,"cos");
		oslDrawString(406,120,"tan");
		oslDrawString(446,120,"ln");
	
		if (osl_keys->pressed.left)
		x -= 1;
		if (x == 0)
		x = 8;

		if (osl_keys->pressed.right)
		x += 1;
		if (x == 10)
		x = 1;

		if (osl_keys->pressed.up)
		y -= 1;
		if (y == 0)
		y = 4;

		if (osl_keys->pressed.down)
		y += 1;
		if (y == 5)
		y = 1;
			
			if (y == 1 && x ==1)
			{
				oslIntraFontSetStyle(Roboto, 0.8f,RED,0,0);
				oslDrawString(35,120,"7");
			}
			else if (y == 1 && x == 2)
			{
				oslIntraFontSetStyle(Roboto, 0.8f,RED,0,0);
				oslDrawString(90,120,"8");
			}
			else if (y == 1 && x  == 3) 
			{
				oslIntraFontSetStyle(Roboto, 0.8f,RED,0,0);
				oslDrawString(145,120,"9");
			}
			else if (y == 1 && x == 4)
			{
				oslIntraFontSetStyle(Roboto, 0.8f,RED,0,0);
				oslDrawString(218,120,"/");
			}
			else if (y == 1 && x == 5)
			{
				oslIntraFontSetStyle(Roboto, 0.6f,RED,0,0);
				oslDrawString(260,120,"DEL");
			}
			else if (y == 1 && x  == 6) 
			{
				oslIntraFontSetStyle(Roboto, 0.6f,RED,0,0);
				oslDrawString(326,120,"sin");
			}
			else if (y == 1 && x  == 7)
			{
				oslIntraFontSetStyle(Roboto, 0.6f,RED,0,0);
				oslDrawString(366,120,"cos");
			}
			else if (y == 1 && x  == 8)
			{
				oslIntraFontSetStyle(Roboto, 0.6f,RED,0,0);
				oslDrawString(406,120,"tan");
			}
			else if (y == 1 && x  == 9)
			{
				oslIntraFontSetStyle(Roboto, 0.6f,RED,0,0);
				oslDrawString(446,120,"ln");
			}
			
			if (y == 2 && x == 1)
			{
				oslIntraFontSetStyle(Roboto, 0.8f,RED,0,0);
				oslDrawString(35,160,"4");
			}
			else if (y == 2 && x == 2) 
			{
				oslIntraFontSetStyle(Roboto, 0.8f,RED,0,0);
				oslDrawString(90,160,"5");
			}
			else if (y == 2 && x == 3)
			{
				oslIntraFontSetStyle(Roboto, 0.8f,RED,0,0);
				oslDrawString(145,160,"6");
			}
			else if (y == 2 && x == 4) 
			{
				oslIntraFontSetStyle(Roboto, 0.8f,RED,0,0);
				oslDrawString(218,160,"x");
			}

			if (y == 3 && x == 1)
			{
				oslIntraFontSetStyle(Roboto, 0.8f,RED,0,0);
				oslDrawString(35,200,"1");
			}
			else if (y == 3 && x == 2)
			{
				oslIntraFontSetStyle(Roboto, 0.8f,RED,0,0);
				oslDrawString(90,200,"2");
			}
			else if (y == 3 && x == 3)
			{
				oslIntraFontSetStyle(Roboto, 0.8f,RED,0,0);
				oslDrawString(145,200,"3");
			}
			else if (y == 3 && x == 4)
			{
				oslIntraFontSetStyle(Roboto, 0.8f,RED,0,0);
				oslDrawString(218,200,"-");
			}	

			if (y == 4 && x == 1)
			{
				oslIntraFontSetStyle(Roboto, 0.8f,RED,0,0);
				oslDrawString(90,240,"0");
			}
			else if (y == 4 && x == 2)
			{
				oslIntraFontSetStyle(Roboto, 0.8f,RED,0,0);
				oslDrawString(218,240,"+");
			}
		
		if (osl_keys->pressed.square)
		{
			powermenu();
		}
		
		if (osl_keys->pressed.circle)
		{	
			oslDeleteImage(calcbackground);
			appdrawer();
		}
		
		if (osl_keys->pressed.L)
		{
			oslPlaySound(Lock, 1);  
			lockscreen();
        }
		
		captureScreenshot();
		
        oslEndDrawing(); 
		oslEndFrame(); 
		oslSyncFrame();
	}
	return 0;
}
Ejemplo n.º 17
0
main(void)
{


    configure(2,2,2,3,1,1);
    set_pattern(pattern);

    neu = 1;
    ziel_id = -1;
    scanwinkel = 0;
    aufloes = 44;


    while(1)
    {
        ziel_id = scan(scanwinkel,aufloes,&ziel_entfernung);
        if (ziel_id == -1)
        {
            aufloes = 44;
            neu = 1;
            do
            {
                if (ziel_id == -1) scanwinkel+=90;
                ziel_id = scan(scanwinkel,aufloes,&ziel_entfernung);
            } while (ziel_id == -1);
        }
        while ( (aufloes>1) && (neu))
        {
            aufloes = aufloes / 2;
            scanwinkel = scanwinkel - (aufloes / 2);
            if (scanwinkel < 0) scanwinkel += 360;
            ziel_id = scan(scanwinkel,aufloes,&ziel_entfernung);
            if (ziel_id == -1) scanwinkel += (aufloes*2);
        }
        neu = 0;

        runde = ticks();
       if ( runde > (geschossen+49) )
       {
           shoot(scanwinkel,ziel_entfernung);
           geschossen = ticks();
       }
       else
       {
           if (ziel_entfernung > 100)
           {
               ladung = battery();
               ladung = ladung / 100;
               switch (ladung)
               {

                    case 1 :
                    case 2 :
                    case 3 : movement(0,scanwinkel);
                             break;
                    case 4 :
                    case 5 : movement(30,scanwinkel);
                             break;

                    default: movement(50,scanwinkel);
                }
            }
            else movement(0,scanwinkel);
        }



    }  /* of while(1) */
}  /* main() */
Ejemplo n.º 18
0
void MP3Play(char * path)
{	
	struct ID3Tag ID3;

	nowplaying = oslLoadImageFilePNG(nowplayingBgPath, OSL_IN_RAM, OSL_PF_8888);
	mp3Play = oslLoadImageFilePNG("system/app/apollo/play.png", OSL_IN_RAM, OSL_PF_8888);
	mp3Pause = oslLoadImageFilePNG("system/app/apollo/pause.png", OSL_IN_RAM, OSL_PF_8888);
	
	if (!nowplaying)
		debugDisplay();
	
	scePowerSetClockFrequency(333, 333, 166);
	
	pspAudioInit();
	
	int i, mp3Min = 0;
	MP3ME_Init(1);
	ParseID3(path, &ID3);
	MP3ME_Load(path);
	MP3ME_Play();
	
	isPlaying = 1;
	
	while (!osl_quit)
	{
		LowMemExit();
		
		oslStartDrawing();		
		
		oslClearScreen(RGB(0,0,0));

		oslReadKeys();
		
		oslIntraFontSetStyle(Roboto, fontSize, BLACK, 0, 0);
		
		if (MP3ME_playingTime > 59)
		{
			mp3Min += 1;
			MP3ME_playingTime = 0;
		}
		oslDrawImageXY(nowplaying, 0, 0);
		oslDrawStringf(240,76, "Playing: %.19s", folderIcons[current].name);
		oslDrawStringf(240,96, "Title: %.21s", ID3.ID3Title);
		
		oslDrawStringf(240,116, "Artist: %.20s", ID3.ID3Artist);
		oslDrawStringf(240,136, "Album: %.21s", ID3.ID3Album);
		oslDrawStringf(240,156, "Year: %.22s", ID3.ID3Year);
		oslDrawStringf(240,176, "Genre: %.21s", ID3.ID3GenreText);
		oslDrawStringf(435,206, "0%d:%.f", mp3Min, MP3ME_playingTime);
		
		if (MP3ME_isPlaying == 1)
			oslDrawImageXY(mp3Play, 230, 224);
		if (MP3ME_isPlaying == 0)
			oslDrawImageXY(mp3Pause, 230, 224);
		
		battery(370,2,1);
		digitaltime(420,4,0,hrTime);
		volumeController();
		
		if(osl_keys->pressed.select) 
		{
			oslDeleteImage(nowplaying);
			oslDeleteImage(mp3Play);
			oslDeleteImage(mp3Pause);
			return;
		}
		
		if(MP3ME_isPlaying == 1 && osl_keys->pressed.cross) 
		{
			oslPlaySound(KeypressStandard, 1); 
			MP3ME_Pause();
			for(i=0; i<10; i++) 
			{
				sceDisplayWaitVblankStart();
			}
		}
		
		else if (MP3ME_isPlaying == 0 && osl_keys->pressed.cross)
		{
			MP3ME_Play();
		}
			
		if (MP3ME_EndOfStream() == 1) 
		{
			isPlaying = 0;
			endAudioLib();
			MP3ME_Stop();
			releaseAudio();
			MP3ME_Play();
		}
		
		if(osl_keys->pressed.circle)
		{
			endAudioLib();
			MP3ME_Stop();
			releaseAudio();
			oslDeleteImage(nowplaying);
			oslDeleteImage(mp3Play);
			oslDeleteImage(mp3Pause);
			isPlaying = 0;
			setCpuBoot(); //Restore previous CPU state
			return;
		}
		
		if (osl_keys->pressed.square)
		{
			powermenu();
		}
		
		if (osl_keys->pressed.L)
		{
			oslPlaySound(Lock, 1);  
			lockscreen();
		}
	
		captureScreenshot();
		
		oslEndDrawing(); 
        oslEndFrame(); 
		oslSyncFrame();	
		}
}
Ejemplo n.º 19
0
int sc_main(int argc, char* argv[]) {

	/** Signals **/

	/** Extern **/
	sc_signal<bool> reset;

	//Battery
	sc_signal<sc_uint<8> > level_change;
	sc_signal<bool> batt_trig;

	//Prox
	sc_signal<sc_uint<3> > prox_input;

	//Pos
	sc_signal<sc_uint<8> > x_pos;
	sc_signal<sc_uint<8> > y_pos;
	sc_signal<sc_uint<8> > z_pos;

	//Motor
	sc_signal<bool> motor_clk;

	//Comm
	sc_signal<sc_uint<8> > signal_quality;
	sc_signal<sc_uint<8> > external_command;
	sc_signal<sc_uint<8> > external_command_arg1;
	sc_signal<sc_uint<8> > external_command_arg2;
	sc_signal<sc_uint<8> > external_command_arg3;

	/** Intern **/

	//Comm
	sc_signal<bool> connected;
	sc_signal<sc_uint<8> > internal_command;
	sc_signal<sc_uint<8> > internal_command_arg1;
	sc_signal<sc_uint<8> > internal_command_arg2;
	sc_signal<sc_uint<8> > internal_command_arg3;

	//Batt
	sc_signal<bool> batt_warning;

	//Pos
	sc_signal<sc_uint<8> > x_pos_internal;
	sc_signal<sc_uint<8> > y_pos_internal;
	sc_signal<sc_uint<8> > z_pos_internal;

	//Prox
	sc_signal<sc_uint<3> > prox_warning;

	//Move
	sc_signal<sc_uint<8> > x_dest;
	sc_signal<sc_uint<8> > y_dest;
	sc_signal<sc_uint<8> > z_dest;
	
	sc_signal<sc_int<8> > x_move_vect;
	sc_signal<sc_int<8> > y_move_vect;
	sc_signal<sc_int<8> > z_move_vect;

	sc_signal<sc_int<8> > x_delta;
	sc_signal<sc_int<8> > y_delta;
	sc_signal<sc_int<8> > z_delta;

	/** Modules **/

	comm comm("comm");
	//In
	comm.reset(reset);
	comm.signal_quality(signal_quality);
	comm.external_command(external_command);
	comm.external_command_arg1(external_command_arg1);
	comm.external_command_arg2(external_command_arg2);
	comm.external_command_arg3(external_command_arg3);
	//Out
	comm.connected(connected);
	comm.internal_command(internal_command);
	comm.internal_command_arg1(internal_command_arg1);
	comm.internal_command_arg2(internal_command_arg2);
	comm.internal_command_arg3(internal_command_arg3);

	battery battery("battery");
	//In
	battery.reset(reset);
	battery.trig(batt_trig);
	battery.level_change(level_change);
	//Out
	battery.warning(batt_warning);

	mainlogic mainlogic("mainlogic");
	//In
	mainlogic.reset(reset);
	mainlogic.x_pos(x_pos_internal);
	mainlogic.y_pos(y_pos_internal);
	mainlogic.z_pos(z_pos_internal);
	mainlogic.prox_warning(prox_warning);
	mainlogic.comm_connected(connected);
	mainlogic.comm_instruction(internal_command);
	mainlogic.comm_instruction_arg1(internal_command_arg1);
	mainlogic.comm_instruction_arg2(internal_command_arg2);
	mainlogic.comm_instruction_arg3(internal_command_arg3);
	mainlogic.battery_warning(batt_warning);
	//Out
	mainlogic.x_dest(x_dest);
	mainlogic.y_dest(y_dest);
	mainlogic.z_dest(z_dest);

	motor motor("motor");
	//In
	motor.reset(reset);
	motor.clock(motor_clk);
	motor.x_move_vect(x_move_vect);
	motor.y_move_vect(y_move_vect);
	motor.z_move_vect(z_move_vect);
	//Out
	motor.x_delta(x_delta);
	motor.y_delta(y_delta);
	motor.z_delta(z_delta);

	motorcontrol motorcontrol("motorcontrol");
	//In
	motorcontrol.reset(reset);
	motorcontrol.x_pos(x_pos_internal);
	motorcontrol.y_pos(y_pos_internal);
	motorcontrol.z_pos(z_pos_internal);
	motorcontrol.x_dest(x_dest);
	motorcontrol.y_dest(y_dest);
	motorcontrol.z_dest(z_dest);
	//Out
	motorcontrol.x_move_vect(x_move_vect);
	motorcontrol.y_move_vect(y_move_vect);
	motorcontrol.z_move_vect(z_move_vect);

	proximitysensor proximitysensor("proximitysensor");
	//In
	proximitysensor.reset(reset);
	proximitysensor.nearby_object(prox_input);
	//Out
	proximitysensor.warning(prox_warning);

	positionsensor positionsensor("positionsensor");
	//In
	positionsensor.reset(reset);
	positionsensor.x_reading(x_pos);
	positionsensor.y_reading(y_pos);
	positionsensor.z_reading(z_pos);
	//Out
	positionsensor.x_value(x_pos_internal);
	positionsensor.y_value(y_pos_internal);
	positionsensor.z_value(z_pos_internal);

	/** VCD File **/

	sc_trace_file *wf = sc_create_vcd_trace_file("trace");

	/** Extern **/

	sc_trace(wf, reset, "reset");
	//Battery
	sc_trace(wf, level_change, "level_change");
	sc_trace(wf, batt_trig, "batt_trig");
	//Prox
	sc_trace(wf, prox_input, "prox_input");
	//Pos
	sc_trace(wf, x_pos, "x_pos");
	sc_trace(wf, y_pos, "y_pos");
	sc_trace(wf, z_pos, "z_pos");
	//Motor
	sc_trace(wf, motor_clk, "motor_clk");
	//Comm
	sc_trace(wf, signal_quality, "reset");
	sc_trace(wf, external_command, "external_command");
	sc_trace(wf, external_command_arg1, "external_command_arg1");
	sc_trace(wf, external_command_arg2, "external_command_arg2");
	sc_trace(wf, external_command_arg3, "external_command_arg3");

	/** Intern **/

	sc_trace(wf, connected, "connected");
	sc_trace(wf, internal_command, "internal_command");
	sc_trace(wf, internal_command_arg1, "internal_command_arg1");
	sc_trace(wf, internal_command_arg2, "internal_command_arg2");
	sc_trace(wf, internal_command_arg3, "internal_command_arg3");

	sc_trace(wf, batt_warning, "batt_warning");

	sc_trace(wf, x_pos_internal, "x_pos_internal");
	sc_trace(wf, y_pos_internal, "y_pos_internal");
	sc_trace(wf, z_pos_internal, "z_pos_internal");

	sc_trace(wf, x_dest, "x_dest");
	sc_trace(wf, y_dest, "y_dest");
	sc_trace(wf, z_dest, "z_dest");

	sc_trace(wf, prox_warning, "prox_warning");

	sc_trace(wf, x_move_vect, "x_move_vect");
	sc_trace(wf, y_move_vect, "y_move_vect");
	sc_trace(wf, z_move_vect, "z_move_vect");

	sc_trace(wf, x_delta, "x_delta");
	sc_trace(wf, y_delta, "y_delta");
	sc_trace(wf, z_delta, "z_delta");

	/** Simulation **/

	sc_start(1, SC_NS, SC_RUN_TO_TIME);

	reset = 1;
	sc_start(1, SC_NS, SC_RUN_TO_TIME);
	reset = 0;
	sc_start(1, SC_NS, SC_RUN_TO_TIME);

	level_change = 1;
	for (int i = 0 ;i < 96;i++) {
		batt_trig = 1;
		sc_start(1, SC_NS, SC_RUN_TO_TIME);
		batt_trig = 0;
		sc_start(1, SC_NS, SC_RUN_TO_TIME);
	}

	sc_close_vcd_trace_file(wf);
	return 0;
 }