Esempio n. 1
0
/**
  * @brief  Show dialogue

  * @param titleString: A string which being shown as title of the dialogue

			 subString0:  First line of the passage

					 subString1:  Second Line of the passage

  */
void ShowDialogue(const char titleString[], const char subString0[], const char subString1[], bool titleCentered, bool stringCentered)
{
	u8 titleAddr, subString0Addr, subString1Addr;
	xSemaphoreTake(OLEDRelatedMutex, portMAX_DELAY);
	OLED_DrawRect(0, 0, 127, 63, DRAW);
	OLED_DrawHorizonalLine(13, 0, 127, 1);
	if (titleCentered == true)
	{
		titleAddr = 63 - GetStringGraphicalLength(titleString) * 3;
		OLED_ShowAnyString(titleAddr, 1, titleString, NotOnSelect, 12);
	}
	else OLED_ShowAnyString(3, 1, titleString, NotOnSelect, 12);
	if (stringCentered == true)
	{
		subString0Addr = 63 - GetStringGraphicalLength(subString0) * 4;
		subString1Addr = 63 - GetStringGraphicalLength(subString1) * 4;
		OLED_ShowAnyString(subString0Addr, 16, subString0, NotOnSelect, 16);
		OLED_ShowAnyString(subString1Addr, 42, subString1, NotOnSelect, 16);
	}
	else
	{
		OLED_ShowAnyString(4, 16, subString0, NotOnSelect, 16);
		OLED_ShowAnyString(4, 42, subString1, NotOnSelect, 16);
	}
	OLED_InvertRect(1, 1, 126, 13);
	xSemaphoreGive(OLEDRelatedMutex);
}
Esempio n. 2
0
/**
  * @brief  Show small dialogue

  * @param  string: Passage

			time:   Time of the dialoue that lasts

			occupyThread:Will ShowSmallDialogue() occupies thread
until time is up
  */
void ShowSmallDialogue(const char string[], u16 time, bool occupyThread)
{
	u8 startAddr, endAddr;
	u8 stringLength;
	stringLength = GetStringGraphicalLength(string);
	startAddr = 63 - stringLength * 4;
	endAddr = startAddr + stringLength * 8;
	xSemaphoreTake(OLEDRelatedMutex, portMAX_DELAY);
	OLED_Clear();
	OLED_DrawRect(startAddr - 4, 20, endAddr + 4, 44, DRAW);
	OLED_ShowAnyString(startAddr, 24, string, NotOnSelect, 16);
	OLED_Refresh_Gram();
	if (occupyThread)
	{
		vTaskDelay(time / portTICK_RATE_MS);
	}
	xSemaphoreGive(OLEDRelatedMutex);
	if (occupyThread)
	{
		xSemaphoreTake(OLEDRelatedMutex, portMAX_DELAY);
		OLED_Clear();
		xSemaphoreGive(OLEDRelatedMutex);
	}
}
Esempio n. 3
0
void UI_ListView_Handler(void *pvParameters)
{
	ListView_Param_Struct* listView_Params = pvParameters;
	Key_Message_Struct key_Message;
	u16 pos[5];
	char tempString[29];
	int currentPos;
	int currentRelativePos;
	u16 itemStringLengths[4];
	u16 lastSelected = listView_Params->DefaultPos;
	u16 lengthTemp;
	u16 posTemp;
	u16 i, p, m;
	u8 displayLineNumInSinglePage = listView_Params->ListLength > 5 ? 5 : listView_Params->ListLength;
	//	u16* dataNumPointer;
	float * dataPointers[4];
	bool updateNumTab = true;
	bool firstDraw = true;
	bool currentPosChanged = false;
	xSemaphoreTake(OLEDRelatedMutex, portMAX_DELAY);
	OLED_Clear();
	OLED_DrawRect(0, 0, 127, 23 + 10 * (displayLineNumInSinglePage - 1), DRAW);
	OLED_DrawHorizonalLine(13, 0, 127, 1);
	xSemaphoreGive(OLEDRelatedMutex);
	SetKeyBeatRate(listView_Params->FastSpeed);
	/*Get the lengths of the itemNames*/
	for (i = 0; i < listView_Params->ItemNum; i++)
	{
		itemStringLengths[i] = GetStringGraphicalLength(listView_Params->ItemNames[i]);
	}
	pos[0] = listView_Params->ItemPositions[0];
	/*Make the positions of the itemStrings centural between two grids*/
	for (i = 0; i < listView_Params->ItemNum; i++)
	{
		pos[i] = GetCentralPosition(listView_Params->ItemPositions[i],
			listView_Params->ItemPositions[i + 1], itemStringLengths[i]) - 1;
	}
	for (i = 0; i < listView_Params->ItemNum; i++)
	{
		OLED_ShowAnyString(pos[i], 1, listView_Params->ItemNames[i], NotOnSelect, 12);
	}
	/*Draw vertical grids*/
	for (i = 0; i < listView_Params->ItemNum; i++)
	{
		OLED_DrawVerticalLine(listView_Params->ItemPositions[i] - 2, 0, 23 + 10 * (displayLineNumInSinglePage - 1), 1);
	}
	/*Draw horizonal grids*/
	for (i = 0; i < displayLineNumInSinglePage; i++)
	{
		OLED_DrawHorizonalLine(23 + 10 * i, 0, 127, 1);
	}
	if (listView_Params->Item1AutoNum == true)
	{
		for (i = 0; i < listView_Params->ItemNum - 1; i++)
		{
			dataPointers[i + 1] = listView_Params->DataPointers[i];
		}
		//		dataNumPointer = listView_Params->DataAutoNumPointer;
		//		for (i = 0; i < listView_Params->ListLength; i++)
		//		{
		//			dataNumPointer[i] = listView_Params->Item1AutoNumStart + i*listView_Params->Item1AutoNumStep;
		//		}
	}
	else
	{
		for (i = 0; i < listView_Params->ItemNum; i++)
		{
			dataPointers[i] = listView_Params->DataPointers[i];
		}
	}
	currentPos = listView_Params->DefaultPos;
	currentRelativePos = 0;
	ClearKeyEvent();
	for (;;)
	{
		xSemaphoreTake(OLEDRelatedMutex, portMAX_DELAY);
		if (listView_Params->Item1AutoNum == true) p = 1;
		else p = 0;
		for (i = 0; i < listView_Params->ItemNum - p; i++)
		{
			for (m = 0; m < displayLineNumInSinglePage; m++)
			{
				sprintf(tempString, listView_Params->sprintfCommandStrings[i], dataPointers[i + p][currentPos + m]);
				lengthTemp = GetStringGraphicalLength(tempString);
				posTemp = GetCentralPosition(listView_Params->ItemPositions[i + p],
					listView_Params->ItemPositions[i + p + 1], lengthTemp);
				OLED_ShowAnyString(posTemp - 1, 15 + 10 * m, tempString, NotOnSelect, 8);
			}
		}

		if (listView_Params->Item1AutoNum == true)
		{
			if (currentPosChanged == true)
			{
				currentPosChanged = false;
				for (i = 0; i < displayLineNumInSinglePage; i++)
					OLED_FillRect(listView_Params->ItemPositions[0], 15 + 10 * i,
						listView_Params->ItemPositions[1] - 4, 22 + 10 * i, 0);
				firstDraw = true;
				updateNumTab = true;
			}
			for (i = 0; i < displayLineNumInSinglePage; i++)
			{
				sprintf(tempString, "%d", listView_Params->Item1AutoNumStart + (currentPos + i)*listView_Params->Item1AutoNumStep);
				lengthTemp = GetStringGraphicalLength(tempString);
				posTemp = GetCentralPosition(listView_Params->ItemPositions[0],
					listView_Params->ItemPositions[1], lengthTemp);
				if (currentRelativePos != i&&lastSelected != i)
					OLED_ShowAnyString(posTemp - 1, 15 + 10 * i, tempString, NotOnSelect, 8);
				if (currentRelativePos == i&&updateNumTab == true)
				{
					if (firstDraw == false)
						OLED_InvertRect(listView_Params->ItemPositions[0], 15 + 10 * lastSelected,
							listView_Params->ItemPositions[1] - 4, 22 + 10 * lastSelected);
					else firstDraw = false;
					OLED_ShowAnyString(posTemp - 1, 15 + 10 * i, tempString, NotOnSelect, 8);
					OLED_InvertRect(listView_Params->ItemPositions[0], 15 + 10 * i,
						listView_Params->ItemPositions[1] - 4, 22 + 10 * i);
					lastSelected = currentRelativePos;
					updateNumTab = false;
				}
			}
		}
		OLED_Refresh_Gram();
		xSemaphoreGive(OLEDRelatedMutex);
		xQueueReceive(Key_Message, &key_Message, portMAX_DELAY);
		if (key_Message.KeyEvent == RightClick || key_Message.AdvancedKeyEvent == RightContinous)
		{
			currentRelativePos++;
			updateNumTab = true;
			if (currentRelativePos >= displayLineNumInSinglePage)
			{
				currentPosChanged = true;
				currentPos++;
				if (currentPos + displayLineNumInSinglePage > listView_Params->ListLength)
				{
					currentPos = listView_Params->ListLength - displayLineNumInSinglePage;
					currentPosChanged = false;
					updateNumTab = false;
				}
				currentRelativePos = displayLineNumInSinglePage - 1;
			}
		}
		else if (key_Message.KeyEvent == LeftClick || key_Message.AdvancedKeyEvent == LeftContinous)
		{
			currentRelativePos--;
			updateNumTab = true;
			if (currentRelativePos < 0)
			{
				currentPosChanged = true;
				currentPos--;
				if (currentPos < 0)
				{
					currentPos = 0;
					currentPosChanged = false;
					updateNumTab = false;
				}
				currentRelativePos = 0;
			}
		}
		else if (key_Message.KeyEvent == MidDouble)
		{
			currentPos = 32767;
			xQueueSend(UI_ListViewMsg, &currentPos, portMAX_DELAY);
			for(;;) vTaskDelay(portMAX_DELAY);
		}
		else if (key_Message.KeyEvent == MidClick)
		{
			xQueueSend(UI_ListViewMsg, &currentPos, portMAX_DELAY);
			for(;;) vTaskDelay(portMAX_DELAY);
		}
	}
}
Esempio n. 4
0
/***	DemoRun()
**
**	Parameters:
**		none
**
**	Return Value:
**		none
**
**	Errors:
**		If demo shut down without proper exit, could damage PmodOLED.
**
**	Description:
**		Displays Demo message and each available Fill Pattern.
**		Pauses between runs to check if user wants to continue, if not, exits.
**		To be safe, exit through prompt before closing demo.
**		Requires UART connection to terminal program on PC.
*/
void DemoRun()
{

	int irow, ib, i;
	u8 *pat;
	char c;

	xil_printf("UART and SPI opened for PmodOLED Demo\n\r");

	while (1)
	{
		//Choosing Fill pattern 0
		pat = OLED_GetStdPattern(0);
		OLED_SetFillPattern(&myDevice, pat);
		//Turn automatic updating off
		OLED_SetCharUpdate(&myDevice, 0);

		//Draw a rectangle over writing then slide the rectangle
		//down slowly displaying all writing
		for (irow = 0; irow < OledRowMax; irow++)
		{
			OLED_ClearBuffer(&myDevice);
			OLED_SetCursor(&myDevice, 0, 0);
			OLED_PutString(&myDevice, "PmodOLED");
			OLED_SetCursor(&myDevice, 0, 1);
			OLED_PutString(&myDevice, "by Digilent");
			OLED_SetCursor(&myDevice, 0, 2);
			OLED_PutString(&myDevice, "Simple Demo");

			OLED_MoveTo(&myDevice, 0, irow);
			OLED_FillRect(&myDevice, 127, 31);
			OLED_MoveTo(&myDevice, 0, irow);
			OLED_LineTo(&myDevice, 127, irow);
			OLED_Update(&myDevice);
			OLED_Delay(100);
		}

		OLED_Delay(1000);
		// Blink the display three times.
		for (i = 0; i < 3; i++)
		{
			OLED_DisplayOff	(&myDevice);
			OLED_Delay		(500);
			OLED_DisplayOn	(&myDevice);
			OLED_Delay		(500);
		}
		OLED_Delay(2000);

		// Now erase the characters from the display
		for (irow = OledRowMax-1; irow >= 0; irow--) {
			OLED_SetDrawColor(&myDevice, 1);
			OLED_SetDrawMode(&myDevice, OledModeSet);
			OLED_MoveTo(&myDevice, 0, irow);
			OLED_LineTo(&myDevice, 127, irow);
			OLED_Update(&myDevice);
			OLED_Delay(25);
			OLED_SetDrawMode(&myDevice, OledModeXor);
			OLED_MoveTo(&myDevice, 0, irow);
			OLED_LineTo(&myDevice, 127, irow);
			OLED_Update(&myDevice);
		}

		OLED_Delay(1000);

		// Draw a rectangle in center of screen
		// Display the 8 different patterns available
		OLED_SetDrawMode(&myDevice, OledModeSet);

		for(ib = 1; ib < 8; ib++)
		{
			OLED_ClearBuffer(&myDevice);
			pat = OLED_GetStdPattern(ib);
			OLED_SetFillPattern(&myDevice, pat);
			OLED_MoveTo(&myDevice, 55, 1);
			OLED_FillRect(&myDevice, 75, 27);
			OLED_DrawRect(&myDevice, 75, 27);
			OLED_Update(&myDevice);

			OLED_Delay(1000);
		}
		xil_printf("(q)uit or any key to continue:\n\r");
		c = inbyte();
		if (c == 'q' || c == 'Q')
			break;
	}
	xil_printf("Exiting PmodOLED Demo\n\r");
}