Commit dcab5219 authored by Iulian Gheorghiu's avatar Iulian Gheorghiu

Update example project to display sensors values on a 32x128 pixel display

parent 9e4b45bc
......@@ -573,6 +573,10 @@ _continue:
#endif
}
}
#ifdef __Xmega_FPGA__
bool state_hbtn_0;
GI::IO::read((char *)"hbtn-0", &state_hbtn_0);
#endif
#ifdef _USE_HIH613x
if(hih613timer.tick())
{
......@@ -1096,7 +1100,11 @@ _continue:
}
#endif
#ifdef _USE_LSM9DS1
if(lsm9ds1_timer.tick())
if(lsm9ds1_timer.tick()
#ifdef __Xmega_FPGA__
&& state_hbtn_0 == false
#endif
)
{
#ifdef _USE_SSD1306
ssd1306_0->clear(Color::Black);
......@@ -1112,7 +1120,9 @@ _continue:
#ifdef _USE_SSD1306
if(ssd1306_0)/* This display driver is used like an external device (non registered display driver), you can declare more displays in this form, even multiplexed on same SPI interface. */
{
GI::String tmpString = GI::String((string)" %3.2f Gr Celsius", lsm9ds1_Temp);
unsigned char gr = (unsigned char)lsm9ds1_Temp;
unsigned char gr_dec = (lsm9ds1_Temp - (float)gr) * 100.0;
GI::String tmpString = GI::String((string)" %3d.%2d Gr Celsius", gr, gr_dec);
ssd1306_0->drawString(tmpString.buff, 0, 0, NULL, false, Color::Black, Color::White);
}
#endif
......@@ -1157,7 +1167,7 @@ _continue:
#ifdef _USE_SSD1306
if(ssd1306_0)/* This display driver is used like an external device (non registered display driver), you can declare more displays in this form, even multiplexed on same SPI interface. */
{
GI::String tmpString = GI::String((string)" Xa=%6d,Ya=%6d,Za=%6d", lsm9ds1_Xa, lsm9ds1_Ya, lsm9ds1_Za);
GI::String tmpString = GI::String((string)" XYZa=%6d,%6d,%6d", lsm9ds1_Xa, lsm9ds1_Ya, lsm9ds1_Za);
ssd1306_0->drawString(tmpString.buff, 0, 8, NULL, false, Color::Black, Color::White);
}
#endif
......@@ -1202,7 +1212,7 @@ _continue:
#ifdef _USE_SSD1306
if(ssd1306_0)/* This display driver is used like an external device (non registered display driver), you can declare more displays in this form, even multiplexed on same SPI interface. */
{
GI::String tmpString = GI::String((string)" Xg=%6d,Yg=%6d,Zg=%6d", lsm9ds1_Xg, lsm9ds1_Yg, lsm9ds1_Zg);
GI::String tmpString = GI::String((string)" XYZg=%6d,%6d,%6d", lsm9ds1_Xg, lsm9ds1_Yg, lsm9ds1_Zg);
ssd1306_0->drawString(tmpString.buff, 0, 16, NULL, false, Color::Black, Color::White);
}
#endif
......@@ -1247,7 +1257,7 @@ _continue:
#ifdef _USE_SSD1306
if(ssd1306_0)/* This display driver is used like an external device (non registered display driver), you can declare more displays in this form, even multiplexed on same SPI interface. */
{
GI::String tmpString = GI::String((string)" Xm=%6d,Ym=%6d,Zm=%6d", lsm9ds1_Xm, lsm9ds1_Ym, lsm9ds1_Zm);
GI::String tmpString = GI::String((string)" XYZm=%6d,%6d,%6d", lsm9ds1_Xm, lsm9ds1_Ym, lsm9ds1_Zm);
ssd1306_0->drawString(tmpString.buff, 0, 24, NULL, false, Color::Black, Color::White);
}
#endif
......@@ -1285,28 +1295,37 @@ _continue:
}
#endif
#ifdef _USE_LPS25HB
if(lps25hb_timer.tick())
if(lps25hb_timer.tick()
#ifdef __Xmega_FPGA__
&& state_hbtn_0 == true
#endif
)
{
ssd1306_0->clear(Color::Black);
float lps25hb_Temp = 0.0;
if(!lps25hb_0.readTemp(&lps25hb_Temp))
{
#ifdef _USE_SSD1306
ssd1306_0->clear(Color::Black);
#endif
#if (SHOW_SENSORS_RESULT_ON_SCREEN == 1)
ListBox->Items[15]->Caption->setTextF((string)"LPS25HB: Temp: %3.2f Gr Celsius", lps25hb_Temp);
#else
GI::IO::writeF((char *)CONSOLE_UART_OUT, (string)"LPS25HB: Temp: %3.2f Gr Celsius\r", lps25hb_Temp);
#endif
#if defined(_USE_SSD1306) || defined(_USE_SSD1331)
unsigned char gr = (unsigned char)lps25hb_Temp;
unsigned char gr_dec = (lps25hb_Temp - (float)gr) * 100.0;
GI::String tmpString = GI::String((string)"Temp: %3d.%2d Gr Celsius", gr, gr_dec);
#endif
#ifdef _USE_SSD1306
if(ssd1306_0)/* This display driver is used like an external device (non registered display driver), you can declare more displays in this form, even multiplexed on same SPI interface. */
{
GI::String tmpString = GI::String((string)"Temp:%3.2f Gr Celsius", lps25hb_Temp);
ssd1306_0->drawString(tmpString.buff, 0, 0, NULL, false, Color::Black, Color::White);
}
#endif
#ifdef _USE_SSD1331
if(ssd1331_0)/* This display driver is used like an external device (non registered display driver), you can declare more displays in this form, even multiplexed on same SPI interface. */
{
GI::String tmpString = GI::String((string)"LPS25HB: Temp: %3.2f Gr Celsius", lps25hb_Temp);
ssd1331_0->drawString(tmpString.buff, 0, 0, NULL, false, Color::Black, Color::White);
}
#endif
......@@ -1325,20 +1344,26 @@ _continue:
#else
GI::IO::writeF((char *)CONSOLE_UART_OUT, (string)"LPS25HB: Press: %4.2f\r", lps25hb_Press);
#endif
#if defined(_USE_SSD1306) || defined(_USE_SSD1331)
unsigned short press = (unsigned short)lps25hb_Press;
unsigned char press_dec = (lps25hb_Press - (float)press) * 100.0;
GI::String tmpString = GI::String((string)"Press: %4d.%2d", press, press_dec);
#endif
#ifdef _USE_SSD1306
if(ssd1306_0)/* This display driver is used like an external device (non registered display driver), you can declare more displays in this form, even multiplexed on same SPI interface. */
{
GI::String tmpString = GI::String((string)"Press:%4.2f", lps25hb_Press);
ssd1306_0->drawString(tmpString.buff, 0, 8, NULL, false, Color::Black, Color::White);
}
#endif
#ifdef _USE_SSD1331
if(ssd1331_0)/* This display driver is used like an external device (non registered display driver), you can declare more displays in this form, even multiplexed on same SPI interface. */
{
GI::String tmpString = GI::String((string)"LPS25HB: Press: %4.2f", lps25hb_Press);
ssd1331_0->drawString(tmpString.buff, 0, 8, NULL, false, Color::Black, Color::White);
}
#endif
#ifdef _USE_SSD1306
ssd1306_0->refresh();
#endif
}
/*else
#if (SHOW_SENSORS_RESULT_ON_SCREEN == 1)
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -1160,7 +1160,7 @@ all: $(OUTPUT_FILE_PATH) $(ADDITIONAL_DEPENDENCIES)
$(OUTPUT_FILE_PATH): $(OBJS) $(USER_OBJS) $(OUTPUT_FILE_DEP) $(LIB_DEP) $(LINKER_SCRIPT_DEP)
@echo Building target: $@
@echo Invoking: AVR8/GNU Linker : 4.8.1
$(QUOTE)C:\Program Files (x86)\Atmel\Atmel Toolchain\AVR8 GCC\Native\3.4.1061\avr8-gnu-toolchain\bin\avr-g++.exe$(QUOTE) -o$(OUTPUT_FILE_PATH_AS_ARGS) $(OBJS_AS_ARGS) $(USER_OBJS) $(LIBS) -Wl,-Map="ExampleXmega_FPGA.map" -Wl,-u,vfprintf -Wl,--start-group -Wl,-lm -Wl,--end-group -Wl,--gc-sections -mrelax -mmcu=atxmega32e5
$(QUOTE)C:\Program Files (x86)\Atmel\Atmel Toolchain\AVR8 GCC\Native\3.4.1061\avr8-gnu-toolchain\bin\avr-g++.exe$(QUOTE) -o$(OUTPUT_FILE_PATH_AS_ARGS) $(OBJS_AS_ARGS) $(USER_OBJS) $(LIBS) -Wl,-Map="ExampleXmega_FPGA.map" -Wl,--start-group -Wl,-lm -Wl,--end-group -Wl,--gc-sections -mrelax -mmcu=atxmega32e5
@echo Finished building target: $@
"C:\Program Files (x86)\Atmel\Atmel Toolchain\AVR8 GCC\Native\3.4.1061\avr8-gnu-toolchain\bin\avr-objcopy.exe" -O ihex -R .eeprom -R .fuse -R .lock -R .signature -R .user_signatures "ExampleXmega_FPGA.elf" "ExampleXmega_FPGA.hex"
"C:\Program Files (x86)\Atmel\Atmel Toolchain\AVR8 GCC\Native\3.4.1061\avr8-gnu-toolchain\bin\avr-objcopy.exe" -j .eeprom --set-section-flags=.eeprom=alloc,load --change-section-lma .eeprom=0 --no-change-warnings -O ihex "ExampleXmega_FPGA.elf" "ExampleXmega_FPGA.eep" || exit 0
......
......@@ -164,7 +164,6 @@
<avrgcccpp.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcccpp.compiler.optimization.AllocateBytesNeededForEnum>
<avrgcccpp.compiler.optimization.DebugLevel>Default (-g2)</avrgcccpp.compiler.optimization.DebugLevel>
<avrgcccpp.compiler.warnings.AllWarnings>True</avrgcccpp.compiler.warnings.AllWarnings>
<avrgcccpp.linker.general.UseVprintfLibrary>True</avrgcccpp.linker.general.UseVprintfLibrary>
<avrgcccpp.linker.libraries.Libraries>
<ListValues>
<Value>libm</Value>
......
......@@ -61,7 +61,7 @@
//#define _USE_MPR121 "i2c-0"
//#define _USE_MPU60x0_9150 "i2c-0"
#define _USE_LSM9DS1 "i2c-0"
//#define _USE_LPS25HB "i2c-0"
#define _USE_LPS25HB "i2c-0"
//#define _USE_MCP79410 "i2c-0"
//#define _USE_TCN75A "i2c-0"
//#define _USE_SSD1331 &lcd_UG9664HDDAG01_LANDSCAPE, (string)"spi-0.0", (string)"pc1", (string)"pc13", (string)"pb13", (string)"pb12"
......
......@@ -637,7 +637,6 @@ int GI::Display::Display::drawString(char *string, signed int X, signed int Y, t
gfx_s8 chHeight = 0;
gfx_s32 CharPtr;
gfx_s8 Tmp = 0;
bool CompactWriting = true;
gfx_s32 Cursor_X = X;
gfx_s32 Cursor_Y = Y;
bool ulVisible = true;
......@@ -673,7 +672,7 @@ int GI::Display::Display::drawString(char *string, signed int X, signed int Y, t
{
gfx_u8 Temp;
/* if CompactWriting is true search the character for free cols from right to left and clear them */
if (CompactWriting)
if (!terminalMode)
{
for (Tmp = 1; Tmp < chWidth; Tmp++)
{
......
......@@ -251,6 +251,7 @@ public:
SysErr refresh();
GI::Dev::Gpio* backlight;
void *driverHandler_Ptr;
bool terminalMode;
private:
};
......
......@@ -28,7 +28,7 @@ GI::Device::Sensor::Lps25hb::Lps25hb(string hwPath, unsigned char sa)
GI::Device::Sensor::Lps25hb::~Lps25hb()
{
setPowerDown(LPS25HB_PWR_DOWN_TRUE);
}
SysErr GI::Device::Sensor::Lps25hb::probe()
......@@ -224,18 +224,20 @@ SysErr GI::Device::Sensor::Lps25hb::readPress(float *pressure)
return SYS_ERR_INVALID_HANDLER;
unsigned long addr = LPS25HB_I2CADDR + sa;
hwIo->ctl(GI::IO::IO_CTL_SET_SLAVE_ADDR, &addr);
unsigned char tmp[3];
unsigned char tmp1;
unsigned char tmp2;
unsigned char tmp3;
SysErr err;
if((err = GI::Sensor::Common::readRegs(hwIo, tmp, LPS25HB_STATUS_REG, 1)) != SYS_ERR_OK)
if((err = GI::Sensor::Common::readRegs(hwIo, &tmp1, LPS25HB_STATUS_REG, 1)) != SYS_ERR_OK)
return err;
if(~tmp[0] & (1 << 1))
if(~tmp1 & (1 << 1))
return SYS_ERR_DATA_NOT_READY;
if((err = GI::Sensor::Common::readRegs(hwIo, tmp, LPS25HB_PRESS_OUT_XL, 1)) != SYS_ERR_OK)
if((err = GI::Sensor::Common::readRegs(hwIo, &tmp1, LPS25HB_PRESS_OUT_XL, 1)) != SYS_ERR_OK)
return err;
if((err = GI::Sensor::Common::readRegs(hwIo, tmp + 1, LPS25HB_PRESS_OUT_L, 1)) != SYS_ERR_OK)
if((err = GI::Sensor::Common::readRegs(hwIo, &tmp2, LPS25HB_PRESS_OUT_L, 1)) != SYS_ERR_OK)
return err;
if((err = GI::Sensor::Common::readRegs(hwIo, tmp + 2, LPS25HB_PRESS_OUT_H, 1)) != SYS_ERR_OK)
if((err = GI::Sensor::Common::readRegs(hwIo, &tmp3, LPS25HB_PRESS_OUT_H, 1)) != SYS_ERR_OK)
return err;
*pressure = (tmp[0] + (tmp[1] << 8) + ((unsigned long)tmp[2] << 16)) / 4096.0/* + ((tmp[2] & 0x80) ? 0xFF000000 : 0x00000000)*/;
*pressure = (tmp1 + (tmp2 << 8) + ((unsigned long)tmp3 << 16)) / 4096.0/* + ((tmp[2] & 0x80) ? 0xFF000000 : 0x00000000)*/;
return SYS_ERR_OK;
}
......@@ -30,7 +30,7 @@ GI::Device::Sensor::Lsm9ds1::Lsm9ds1(string hwPath, unsigned char sa0, unsigned
GI::Device::Sensor::Lsm9ds1::~Lsm9ds1()
{
setMagOpMode(LSM9DS1_MAG_OP_MODE_PWR_DOWN);
}
SysErr GI::Device::Sensor::Lsm9ds1::probe()
......
......@@ -1122,8 +1122,7 @@ gfx_s32 GI::Screen::Gfx::String::drawString()
#ifdef __AVR_XMEGA__
pucData = ((const gfx_u8 *)&pFont->pucData + 2 + read_data_word(pusOffset[*pcString++ - ' ']));
#else
pucData = (pFont->pucData
+ read_data_word(pusOffset[*pcString++ - ' ']));
pucData = (pFont->pucData + read_data_word(pusOffset[*pcString++ - ' ']));
#endif
}
else
......@@ -1131,9 +1130,7 @@ gfx_s32 GI::Screen::Gfx::String::drawString()
#ifdef __AVR_XMEGA__
pucData = ((const gfx_u8 *)&pFont->pucData + 2 + read_data_word(pusOffset[ABSENT_CHAR_REPLACEMENT - ' ']));
#else
pucData = (pFont->pucData
+ read_data_word(
pusOffset[ABSENT_CHAR_REPLACEMENT - ' ']));
pucData = (pFont->pucData + read_data_word(pusOffset[ABSENT_CHAR_REPLACEMENT - ' ']));
#endif
pcString++;
}
......@@ -1398,7 +1395,7 @@ gfx_s32 GI::Screen::Gfx::String::drawString()
if(((lY + lY0) >= LcdStruct->sClipRegion.sYMin) && _ulOpaque)
{
if(ulVisible == true)
LcdStruct->drawHLine(lX + lX0, lCount, lY + lY0, 1, background_color);
LcdStruct->drawHLine(lX + lX0, lCount, lY + lY0, 1, background_color);
}
//
......@@ -1597,7 +1594,6 @@ gfx_s32 GI::Screen::Gfx::String::drawStringTiny()
gfx_s8 chHeight = 0;
gfx_s32 CharPtr;
gfx_s8 Tmp = 0;
bool CompactWriting = true;
gfx_s32 Cursor_X = lX;
gfx_s32 Cursor_Y = lY;
gfx_s32 CharCnt = 0;
......@@ -1627,7 +1623,7 @@ gfx_s32 GI::Screen::Gfx::String::drawStringTiny()
else
{
gfx_u8 Temp;
if (CompactWriting)
if (!terminalMode)
{
for (Tmp = 1; Tmp < chWidth; Tmp++)
{
......@@ -1726,7 +1722,6 @@ gfx_s32 GI::Screen::Gfx::String::getStrPropTiny()
gfx_s8 chWidth = 0;
//gfx_s8 chWidth_Tmp = 0;
gfx_s32 CharPtr;
bool CompactWriting = true;
gfx_s32 Cursor_X = 0;
gfx_s32 CharCnt = 0;
#ifdef __AVR_XMEGA__
......@@ -1754,7 +1749,7 @@ gfx_s32 GI::Screen::Gfx::String::getStrPropTiny()
else
{
gfx_u8 Temp;
if (CompactWriting)
if (!terminalMode)
{
for (Tmp = 1; Tmp < chWidth; Tmp++)
{
......
......@@ -114,6 +114,7 @@ namespace Gfx {
*/
gfx_u32 modifyed;
int error;
bool terminalMode;
//bool initialized;
};
}
......
......@@ -62,7 +62,6 @@ GI::String::String(const char *String, ...)
vsnprintf(buff, len + 1, String, args);
va_end (args);
length = len;
error = SYS_ERR_OK;
modifyed++;
}
else
......@@ -87,7 +86,6 @@ GI::String::String(GI::String *String, ...)
vsnprintf(buff, len + 1, pcString, args);
va_end (args);
length = len;
error = SYS_ERR_OK;
modifyed++;
}
else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment