Exemplo n.º 1
0
void print_cell_state (walls cell_state)
{
    #ifdef PRINT_WALLS_DETECTED
    ssd1306ClearRect(64,DISPLAY_OFFSET,54,5);
    ssd1306ClearRect(64,DISPLAY_OFFSET,5,54);
    ssd1306ClearRect(113,DISPLAY_OFFSET,5,54);

    if (cell_state.front == WALL_PRESENCE)
    {
        ssd1306FillRect(64,DISPLAY_OFFSET,54,5);
    }
    if (cell_state.left == WALL_PRESENCE)
    {
        ssd1306FillRect(64,DISPLAY_OFFSET,5,54);
    }
    if (cell_state.right == WALL_PRESENCE)
    {
        ssd1306FillRect(113,DISPLAY_OFFSET,5,54);
    }
    #endif
    #ifdef PRINT_CELL_STATE_BLEUTOOTH
    if (cell_state.front == WALL_PRESENCE)
    {
        bluetoothPrintf("_");
    }
    if (cell_state.left == WALL_PRESENCE)
    {
        bluetoothPrintf("|");
    }
    else
    {
        bluetoothPrintf(" ");
    }
    if (cell_state.right == WALL_PRESENCE)
    {
        bluetoothPrintf("|");
    }
    bluetoothPrintf("\n");
    #endif
}
Exemplo n.º 2
0
int modifyLongParam( char *param_name,long *param)
{
	int step=1;
	char str[40];
	long param_copy = *param;
	char collone=0;
	ssd1306ClearScreen();

	// Write the parameter name
	ssd1306DrawString(0, 0,param_name, &Font_5x8);
	ssd1306DrawLine(0, 9, 128, 9);

	sprintf(str, "%10i", (int)param_copy);
	ssd1306DrawString(0, 28, str, &Font_8x8);
	ssd1306DrawString(0, 50, "PRESS 'RIGHT' TO VALIDATE", &Font_3x6);
	ssd1306DrawString(0, 57, "      'LEFT'  TO RETURN.", &Font_3x6);
	ssd1306DrawString((10-collone)*8,20,"^",&Font_8x8);
	ssd1306DrawString((10-collone)*8,36,"v",&Font_8x8);
	ssd1306Refresh();

	while (1)
	{
		// Exit Button
		int joystick=expanderJoyFiltered();
		switch (joystick)
		{
		case JOY_LEFT :
			if (collone==10)
				return SUCCESS;
			else
			{
				collone++;
				ssd1306ClearRect(0,20,128,8);
				ssd1306ClearRect(0,36,128,8);
				ssd1306DrawString((9-collone)*9,20,"^",&Font_8x8);
				ssd1306DrawString((9-collone)*9,36,"v",&Font_8x8);
				ssd1306Refresh();
			}
			break;
		case JOY_UP:

			//param_copy +=1;
			param_copy += (step*pow(10,collone));
			ssd1306ClearRect(0, 28, 164, 8);
			sprintf(str, "%10i", (int)param_copy);
			ssd1306DrawString(0, 28, str, &Font_8x8);
			ssd1306Refresh();
			break;
		case JOY_DOWN :

			param_copy -= (step*pow(10,collone));
			//param_copy -= 1;
			ssd1306ClearRect(0, 28, 164, 8);
			sprintf(str, "%10i", (int)param_copy);
			ssd1306DrawString(0, 28, str, &Font_8x8);
			ssd1306Refresh();
			break;
		case JOY_RIGHT :
			if(collone==0)
			{
				*param = param_copy;
				ssd1306Refresh();
				return SUCCESS;
			}
			else
			{
				collone--;
				ssd1306ClearRect(0,20,128,8);
				ssd1306ClearRect(0,36,128,8);
				ssd1306DrawString((9-collone)*9,20,"^",&Font_8x8);
				ssd1306DrawString((9-collone)*9,36,"v",&Font_8x8);
				ssd1306Refresh();
			}
			break;
		default:
			break;
		}
	}

	return SUCCESS;
}
Exemplo n.º 3
0
int modifyBoolParam( char *param_name, unsigned char *param)
{
	char str[4];
	bool param_copy = (bool)*param;

	ssd1306ClearScreen();

	// Write the parameter name
	ssd1306DrawString(0, 0,param_name, &Font_5x8);
	ssd1306DrawLine(0, 9, 128, 9);

	if (param_copy == true)
	{
		sprintf(str, "YES");
	}
	else
	{
		sprintf(str, "NO");
	}
	ssd1306DrawString(0, 28, str, &Font_8x8);
	ssd1306DrawString(0, 50, "PRESS 'RIGHT' TO VALIDATE", &Font_3x6);
	ssd1306DrawString(0, 57, "      'LEFT'  TO RETURN.", &Font_3x6);
	ssd1306Refresh();

	while (1)
	{
		int joystick=expanderJoyFiltered();
		switch (joystick)
		{
		case JOY_LEFT :
			return SUCCESS;
			break;

		case JOY_DOWN:
		case JOY_UP :
			if (param_copy == true)
			{
				param_copy = false;
				sprintf(str, "NO");
			}
			else
			{
				param_copy = true;
				sprintf(str, "YES");
			}
			ssd1306ClearRect(0, 28, 164, 8);
			ssd1306DrawString(0, 28, str, &Font_8x8);
			ssd1306Refresh();
			break;

		case JOY_RIGHT:

			*param = param_copy;
			ssd1306ClearScreen();
			ssd1306Refresh();
			return SUCCESS;
			break;
		}
	}
	return SUCCESS;
}