📄 main.cpp
字号:
// for cout
//#include <iostream>
// for printf
//#include "stdio.h"
// Lcd class definition
#include "lcd.h"
// F449 definitions
#include "msp430x44x.h"
// Timer A interrupt service routine
#pragma vector=TIMERA0_VECTOR
__interrupt void Timer( void )
{
_DINT();
// local object to get display control
Lcd lLcd;
// button #1
if( !(P3IN & 0x10) )
{
lLcd.ArrowLeft( true );
lLcd.ArrowUp( true );
lLcd.ArrowDown( true );
lLcd.ArrowRight( true );
}
else
{
lLcd.ArrowLeft( false );
lLcd.ArrowUp( false );
lLcd.ArrowDown( false );
lLcd.ArrowRight( false );
}
// button #2
if( !(P3IN & 0x20) )
lLcd.Olimex( true );
else
lLcd.Olimex( false );
// button #3
if( !(P3IN & 0x40) )
lLcd.SevenSeg( 12, 34 );
else
lLcd.Clear7Seg();
// button #4
if( !(P3IN & 0x80) )
{
lLcd.m( true );
lLcd.u( true );
lLcd.H( true );
lLcd.F( true );
}
else
{
lLcd.m( false );
lLcd.u( false );
lLcd.H( false );
lLcd.F( false );
}
_EINT();
}
void Init( void )
{
// P3.4 to P3.7 set to input buttons
P3DIR |= 0x0F;
// init timer A so that we can
// use this to pool the buttons
TACTL = TASSEL1 + TACLR; // SMCLK, clear TAR
CCTL0 = CCIE; // CCR0 interrupt enabled
CCR0 = 1000;
TACTL |= MC1; // Start timer A in continuous mode
// Enable interrupts
_EINT();
}
int main (void)
{
// stop watchdog timer
WDTCTL = WDTPW + WDTHOLD;
// initialize timer interrupt
// and I/O input on P3
Init();
// these can be released when using the full version
// if released the includes must also be released
// -------------------------------------------------
//const char* date = __DATE__;
//printf("Date : %s ", date);
//const char* time = __TIME__;
//cout << "Time : " << time;
// initialize two object containing "Hello" and "World"
Lcd Hello( "Hello" );
Lcd World( "World", /* upper case == */ false, /* flush == */ false );
// flush the message "World" to the display
World.Flush();
// loop forever so that we have
// time to try the buttons
for(;;);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -