/*
	dacdemo.c

   PK21xx/Rugged Giant (only) sample program.

   This sample program operates the digital to analog converter based upon
   a key press.
   
   The key pressed is used as a multiplier for the output to the dac. The
   DAC output pin can be monitored using a voltmeter.
   
   Uses the calibrated dac values.
*/

#use "default.h"
#use cplc.lib

#if !(BOARD_TYPE==CPLC_BOARD)
#fatal "This program only runs on a Rugged Giant"
#endif

#define NOUNIVERSAL 1        // disable the virtual drivers for the io's

main()
{
    int k;
    
    uplc_init();
    for (k = 0; k < 1000; k++)
        ;                    // delay a bit for the LCD
    lcd_printf(0L, "hello World");

    while (1)
    {
        while ((k = lc_kxget(0)) < 0) 
            runwatch();      // wait for a key
        up_beep(100);
        if (k > 10) 
            k = 10;
        up_daccal(k * 1000);
        lcd_erase_line(1);
        lcd_printf(0x01000000L, "DA >> %6.3f v ",(float)(k) );
        printf("DA >> %6.3f v \n",(float)(k) );
    }
}


