Ejemplo n.º 1
0
int LCD_Display(uint16_t num)
{
	//convertToASCII
	uint8_t displayChar = ConvertToASCII(num);
	
	//place the ASCII character on the D0-D7 lines
	uint8_t i = 0;
	uint8_t result;
	uint8_t andBit = 1;
	while (i < 8){												//for each bit in the ascii character
		result = displayChar & andBit;			//check if that bit is 1
		if(result){ 												//if bit is 1, set the resulting GPIO pin
			SetGPIO(i);
		}else{
			ResetGPIO(i); 										//otherwise, reset the resulting GPIO pin
		}i++;																//increment bit number
		andBit = andBit << 1;								//multiply number used for and-ing by 2
	}
	
	//register Select = 1 to send characters
	GPIO_SetBits(GPIOB, GPIO_Pin_1);
	//Enable pulse (set high - delay - set low)
	GPIO_SetBits(GPIOE, GPIO_Pin_9);
	//delay
	GPIO_ResetBits(GPIOE, GPIO_Pin_9);
	//delay to give LCD the time neeeded to display the character
}
Ejemplo n.º 2
0
VOID DoOpenFile(LPCTSTR szFileName)
{
    static const TCHAR dotlog[] = _T(".LOG");
    HANDLE hFile;
    LPTSTR pszText = NULL;
    DWORD dwTextLen;
    TCHAR log[5];

    /* Close any files and prompt to save changes */
    if (!DoCloseFile())
        return;

    hFile = CreateFile(szFileName, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
                       OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
    if (hFile == INVALID_HANDLE_VALUE)
    {
        ShowLastError();
        goto done;
    }

    if (!ReadText(hFile, (LPWSTR *)&pszText, &dwTextLen, &Globals.iEncoding, &Globals.iEoln))
    {
        ShowLastError();
        goto done;
    }
#ifndef UNICODE
    pszText = ConvertToASCII(pszText);
    if (pszText == NULL) {
        ShowLastError();
        goto done;
    }
#endif
    SetWindowText(Globals.hEdit, pszText);

    SendMessage(Globals.hEdit, EM_SETMODIFY, FALSE, 0);
    SendMessage(Globals.hEdit, EM_EMPTYUNDOBUFFER, 0, 0);
    SetFocus(Globals.hEdit);

    /*  If the file starts with .LOG, add a time/date at the end and set cursor after
     *  See http://support.microsoft.com/?kbid=260563
     */
    if (GetWindowText(Globals.hEdit, log, SIZEOF(log)) && !_tcscmp(log, dotlog))
    {
        static const TCHAR lf[] = _T("\r\n");
        SendMessage(Globals.hEdit, EM_SETSEL, GetWindowTextLength(Globals.hEdit), -1);
        SendMessage(Globals.hEdit, EM_REPLACESEL, TRUE, (LPARAM)lf);
        DIALOG_EditTimeDate();
        SendMessage(Globals.hEdit, EM_REPLACESEL, TRUE, (LPARAM)lf);
    }

    SetFileName(szFileName);
    UpdateWindowCaption();
    NOTEPAD_EnableSearchMenu();
done:
    if (hFile != INVALID_HANDLE_VALUE)
        CloseHandle(hFile);
    if (pszText)
        HeapFree(GetProcessHeap(), 0, pszText);
}