Help with Qtouch buttons [ATtiny817]

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi All

 

I was experimenting with the Qtouch buttons on the tiny817 xplained mini board and would like some help. I used the Atmel Qtouch library found from start.atmel.com (I started with the touch example they had for tiny817 xplained) and added in the LCD code I was working on earlier tweaked to get the process working. As shown in the screenshot, it seems like my project current uses 91.7% of the program memory usage (I assume that is code space, unless I am mistaken) as the screenshot below indicates !!

 

My program that I put together can turn on LED when I press one of the two touch buttons, and turn off LED with the other touch button with the respective LED ON and LED OFF message displayed on the LCD to indicate current status of LED.

 

 

Can anybody help me with the code to figure out how to improve the code so that it doesn't take up so much space so there's more space to add other things that I may want to add and in the meantime also if there are some tips on how to do these things better ?

 

All the files from my project has been attached to this post (in the zip file)

 

 

Thanks so much in advance,

 

 

 

 

 

My current code is below

 

#define F_CPU 3300000UL

#include <atmel_start.h>
#include <avr/io.h>
#include <util/delay.h>
#include <string.h>
#include "lcd.h"
#include "touch.h"

/*****************************************************/

char text1[8] =
{
	"LED ON "
};

char text2[8] =
{
	"LED OFF"
};

char value[] =
{
	//0xDF, 0x01, 0x2, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f
	0x30
};

char unit[] =
{ 0x41
};

/*****************************************************/

int main(void)
{
	uint8_t key_status0 = 0;
	uint8_t key_status1 = 0;

	/* Initializes MCU, drivers and middleware */
	atmel_start_init();
	lcd_init();

	/* Enable interrupts */
	//SREG |= 0x80;
	sei();

	/* If the left self-capacitance button is touched, the LED is turned ON with ON message on LCD
	 * Otherwise, if other button is touched, LED is turned off with OFF message on LCD
	 */
	while (1)
	{
		/* Does acquisition and post-processing */
		touch_process();

		key_status0 = get_sensor_state(0) & 0x80;
		key_status1 = get_sensor_state(1) & 0x80;

		if (0u != key_status0)
		{
			//lcd_clear();
			PORTC.OUTSET = PIN0_bm; // turn on LED
			         //.kbv
			lcd_string(text1);
			//_delay_ms(2500);
			lcd_gotoxy(0, 0);  // move cursor to first line
		}
		else if (0u != key_status1)
		{
			//lcd_init();
			//lcd_clear();
			PORTC.OUTCLR = PIN0_bm; // turn off
			//lcd_init();         //.kbv
			lcd_string(text2);
			lcd_gotoxy(0, 0);  // move cursor to first line
		//	_delay_ms(2500);
		}
	}
}

 

Attachment(s): 

Last Edited: Wed. Feb 14, 2018 - 08:03 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

UPDATE: I found that the Qtouch program that is available from the start.atmel.com page has 89.4% Program memory usage,  according to the atmel studio IDE after I built that program that was already ready to go. This to me means 89.4% of the 8kb flash is being used by the library files and whatnot that is being used and that seems big!

So what's the best way to get Qtouch working without using up so much flash space for even a simple program to just touch a button, turn on a LED (using the Qtouch library files that atmel start provided and such)? 

 

~mc0134