<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="pl-pl">
<link rel="self" type="application/atom+xml" href="https://forum.atnel.pl/feed.php?f=4&amp;t=6866&amp;mode" />

<title>ATNEL tech-forum</title>
<link href="https://forum.atnel.pl/index.php" />
<updated>2014-04-27T21:38:01+01:00</updated>

<author><name><![CDATA[ATNEL tech-forum]]></name></author>
<id>https://forum.atnel.pl/feed.php?f=4&amp;t=6866&amp;mode</id>
<entry>
<author><name><![CDATA[heniug]]></name></author>
<updated>2014-04-27T21:38:01+01:00</updated>
<published>2014-04-27T21:38:01+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=6866&amp;p=79475#p79475</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=6866&amp;p=79475#p79475"/>
<title type="html"><![CDATA[Re: [Eclipse] Problem z kompilacją]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=6866&amp;p=79475#p79475"><![CDATA[
Witam<br />Oto powiązane kody. Dodam że zmiany w obsłudze LCD6610 dotyczą możliwości wyświetlania czcionki 32x16<br /><br />[syntax=c]/************************************************************************/<br />/*                                                                      */<br />/*        Access Dallas 1-Wire Device with ATMEL AVRs                   */<br />/*                                                                      */<br />/*              Author: Peter Dannegger                                 */<br />/*                      danni@specs.de                                  */<br />/*                                                                      */<br />/* modified by Martin Thomas &lt;eversmith@heizung-thomas.de&gt; 9/2004       */<br />/************************************************************************/<br />/*<br /> * ds18x20.c<br /> *<br /> *  Created on: 2009-08-22<br /> *      modyfikacje: Mirosław Kardaś<br /> */<br />#include &lt;avr/io.h&gt;<br />#include &lt;util/delay.h&gt;<br /><br />#include &quot;ds18x20.h&quot;<br />#include &quot;onewire.h&quot;<br />#include &quot;crc8.h&quot;<br /><br /><br /><br />uint8_t gSensorIDs&#91;MAXSENSORS&#93;&#91;OW_ROMCODE_SIZE&#93;;<br /><br /><br /><br />uint8_t DS18X20_meas_to_cel( uint8_t fc, uint8_t *sp,<br />uint8_t* subzero, uint8_t* cel, uint8_t* cel_frac_bits)<br />{<br />uint16_t meas;<br />uint8_t  i;<br />uint8_t t_tab1&#91;16&#93; = {0,1,1,2,2,3,4,4,5,6,6,7,7,8,9,9};<br /><br />meas = sp&#91;0&#93;;  // LSB<br />meas |= ((uint16_t)sp&#91;1&#93;)&lt;&lt;8; // MSB<br />//meas = 0xff5e; meas = 0xfe6f;<br /><br />//  only work on 12bit-base<br />if( fc == DS18S20_ID ) { // 9 -&gt; 12 bit if 18S20<br />/* Extended measurements for DS18S20 contributed by Carsten Foss */<br />meas &amp;= (uint16_t) 0xfffe;// Discard LSB , needed for later extended precicion calc<br />meas &lt;&lt;= 3;// Convert to 12-bit , now degrees are in 1/16 degrees units<br />meas += (16 - sp&#91;6&#93;) - 4;// Add the compensation , and remember to subtract 0.25 degree (4/16)<br />}<br /><br />// check for negative<br />if ( meas &amp; 0x8000 )  {<br />*subzero=1;      // mark negative<br />meas ^= 0xffff;  // convert to positive =&gt; (twos complement)++<br />meas++;<br />}<br />else *subzero=0;<br /><br />// clear undefined bits for B != 12bit<br />if ( fc == DS18B20_ID ) { // check resolution 18B20<br />i = sp&#91;DS18B20_CONF_REG&#93;;<br />if ( (i &amp; DS18B20_12_BIT) == DS18B20_12_BIT );<br />else if ( (i &amp; DS18B20_11_BIT) == DS18B20_11_BIT )<br />meas &amp;= ~(DS18B20_11_BIT_UNDF);<br />else if ( (i &amp; DS18B20_10_BIT) == DS18B20_10_BIT )<br />meas &amp;= ~(DS18B20_10_BIT_UNDF);<br />else { // if ( (i &amp; DS18B20_9_BIT) == DS18B20_9_BIT ) {<br />meas &amp;= ~(DS18B20_9_BIT_UNDF);<br />}<br />}<br /><br />*cel  = (uint8_t)(meas &gt;&gt; 4);<br />*cel_frac_bits = t_tab1&#91;(uint8_t)(meas &amp; 0x000F)&#93;    ;<br /><br /><br />return DS18X20_OK;<br />}<br /><br /><br /><br />/* compare temperature values (full celsius only)<br />   returns -1 if param-pair1 &lt; param-pair2<br />            0 if ==<br />1 if &gt;    */<br />int DS18X20_temp_cmp(uint8_t subzero1, uint16_t cel1,<br />uint8_t subzero2, uint16_t cel2)<br />{<br />int16_t t1 = (subzero1) ? (cel1*(-1)) : (cel1);<br />int16_t t2 = (subzero2) ? (cel2*(-1)) : (cel2);<br /><br />if (t1&lt;t2) return -1;<br />if (t1&gt;t2) return 1;<br />return 0;<br />}<br /><br />/* find DS18X20 Sensors on 1-Wire-Bus<br />   input/ouput: diff is the result of the last rom-search<br />   output: id is the rom-code of the sensor found */<br />void DS18X20_find_sensor(uint8_t *diff, uint8_t id&#91;&#93;)<br />{<br />for (;;) {<br />*diff = ow_rom_search( *diff, &amp;id&#91;0&#93; );<br />if ( *diff==OW_PRESENCE_ERR || *diff==OW_DATA_ERR ||<br />  *diff == OW_LAST_DEVICE ) return;<br />if ( id&#91;0&#93; == DS18B20_ID || id&#91;0&#93; == DS18S20_ID ) return;<br />}<br />}<br /><br /><br /><br />uint8_t search_sensors(void)<br />{<br />uint8_t i;<br />uint8_t id&#91;OW_ROMCODE_SIZE&#93;;<br />uint8_t diff, nSensors;<br /><br />nSensors = 0;<br /><br />for( diff = OW_SEARCH_FIRST;<br />diff != OW_LAST_DEVICE &amp;&amp; nSensors &lt; MAXSENSORS ; )<br />{<br />DS18X20_find_sensor( &amp;diff, &amp;id&#91;0&#93; );<br /><br />if( diff == OW_PRESENCE_ERR ) {<br />break;<br />}<br /><br />if( diff == OW_DATA_ERR ) {<br />break;<br />}<br /><br />for (i=0;i&lt;OW_ROMCODE_SIZE;i++) gSensorIDs&#91;nSensors&#93;&#91;i&#93;=id&#91;i&#93;;<br /><br />nSensors++;<br />}<br /><br />return nSensors;<br />}<br /><br /><br /><br /><br />/* get power status of DS18x20<br />   input  : id = rom_code<br />   returns: DS18X20_POWER_EXTERN or DS18X20_POWER_PARASITE */<br />uint8_tDS18X20_get_power_status(uint8_t id&#91;&#93;)<br />{<br />uint8_t pstat;<br />    ow_reset();<br />    ow_command(DS18X20_READ_POWER_SUPPLY, id);<br />    pstat=ow_bit_io(1); // pstat 0=is parasite/ !=0 ext. powered<br />    ow_reset();<br />return (pstat) ? DS18X20_POWER_EXTERN:DS18X20_POWER_PARASITE;<br />}<br /><br />/* start measurement (CONVERT_T) for all sensors if input id==NULL<br />   or for single sensor. then id is the rom-code */<br />uint8_t DS18X20_start_meas( uint8_t with_power_extern, uint8_t id&#91;&#93;)<br />{<br />ow_reset(); //**<br />if( ow_input_pin_state() ) { // only send if bus is &quot;idle&quot; = high<br />ow_command( DS18X20_CONVERT_T, id );<br />if (with_power_extern != DS18X20_POWER_EXTERN)<br />ow_parasite_enable();<br />return DS18X20_OK;<br />}<br />else {<br /><br />return DS18X20_START_FAIL;<br />}<br />}<br /><br />/* reads temperature (scratchpad) of sensor with rom-code id<br />   output: subzero==1 if temp.&lt;0, cel: full celsius, mcel: frac<br />   in millicelsius*0.1<br />   i.e.: subzero=1, cel=18, millicel=5000 = -18,5000°C */<br />uint8_t DS18X20_read_meas(uint8_t *id, uint8_t *subzero, uint8_t *cel, uint8_t *cel_frac_bits)<br />{<br />uint8_t i;<br />uint8_t sp&#91;DS18X20_SP_SIZE&#93;;<br /><br />ow_reset(); //**<br />ow_command(DS18X20_READ, id);<br />for ( i=0 ; i&lt; DS18X20_SP_SIZE; i++ ) sp&#91;i&#93;=ow_byte_rd();<br />if ( crc8( &amp;sp&#91;0&#93;, DS18X20_SP_SIZE ) )<br />return DS18X20_ERROR_CRC;<br />DS18X20_meas_to_cel(id&#91;0&#93;, sp, subzero, cel, cel_frac_bits);<br />return DS18X20_OK;<br />}<br /><br />/* reads temperature (scratchpad) of a single sensor (uses skip-rom)<br />   output: subzero==1 if temp.&lt;0, cel: full celsius, mcel: frac<br />   in millicelsius*0.1<br />   i.e.: subzero=1, cel=18, millicel=5000 = -18,5000°C */<br />uint8_t DS18X20_read_meas_single(uint8_t familycode, uint8_t *subzero, uint8_t *cel, uint8_t *cel_frac_bits)<br />{<br />uint8_t i;<br />uint8_t sp&#91;DS18X20_SP_SIZE&#93;;<br /><br />ow_command(DS18X20_READ, NULL);<br />for ( i=0 ; i&lt; DS18X20_SP_SIZE; i++ ) sp&#91;i&#93;=ow_byte_rd();<br />if ( crc8( &amp;sp&#91;0&#93;, DS18X20_SP_SIZE ) )<br />return DS18X20_ERROR_CRC;<br />DS18X20_meas_to_cel(familycode, sp, subzero, cel, cel_frac_bits);<br /><br /><br />return DS18X20_OK;<br />}[/syntax]<br /><br />następny<br /><br />[syntax=c]/*   Obsługa wyświetlacza  graficznego LCD6610              */<br /><br /><br /><br />/****************************************************/<br />/* Pin Interface to LCD-NOKIA6610                   */<br />/* PB0 --&gt; LCD_BL(Backlight Control)                */<br />/* PB1 --&gt; LCD_CS#                */<br />/* PB2 --&gt; LCD_SCLK                           */<br />/* PB3 --&gt; LCD_SDATA                                */<br />/* PB4 --&gt; LCD_RESET#                       */<br />/****************************************************/<br />#include &lt;stdio.h&gt;<br />#include &lt;stdlib.h&gt;<br />  <br />#include &lt;avr/io.h&gt;<br /><br />#include &lt;util/delay.h&gt;<br />#include &lt;avr/pgmspace.h&gt;// For Used Array in Code<br />#include &quot;font.h&quot;// Font Table Code<br />#include &quot;LCD6610_NXP.h&quot;// Bitmap Graphic File<br /><br /><br /><br /><br /><br /><br /><br />// *****************************************************************************<br />// WriteSpiCommand.c<br />//<br />// Writes 9-bit command to LCD display via SPI interface<br />//<br />// Inputs: data - Philips PCF8833 controller/driver command<br />//<br />//<br />// Note: clears bit 8 to indicate command transfer<br />//<br />// Author: Olimex, James P Lynch July 7, 2007<br />// *****************************************************************************<br />void WriteSpiCommand(volatile unsigned int command) <br />{  <br />  unsigned char Bit = 0;// Bit Counter<br /><br />  LCD_CS_HI();// Makesure CS = Disable<br />  LCD_SCLK_LO(); // Prepared SCLK<br /><br />  LCD_CS_LO();// Start CS = Enable<br />  LCD_SDATA_LO();  // D/C# = 0(Command)<br />  LCD_SCLK_HI();// Strobe Signal Bit(SDATA)<br />  LCD_SCLK_LO(); // Standby SCLK <br />   <br />  for (Bit = 0; Bit &lt; 8; Bit++)// 8 Bit Write<br />  {<br />    LCD_SCLK_LO();// Standby SCLK <br /><br />if((command&amp;0x80)&gt;&gt;7) <br />{<br />  LCD_SDATA_HI();  <br />}<br />else <br />{<br />  LCD_SDATA_LO();<br />}<br /><br />LCD_SCLK_HI();// Strobe Signal Bit(SDATA)<br /><br />command &lt;&lt;= 1; // Next Bit Data<br />  }  <br />  LCD_SCLK_LO();  // Standby SCLK <br />  LCD_CS_HI();// Stop CS = Disable<br />}<br /><br />// *****************************************************************************<br />// WriteSpiData.c<br />//<br />// Writes 9-bit command to LCD display via SPI interface<br />//<br />// Inputs: data - Philips PCF8833 controller/driver command<br />//<br />//<br />// Note: Sets bit 8 to indicate data transfer<br />//<br />// Author: Olimex, James P Lynch July 7, 2007<br />// *****************************************************************************<br />void WriteSpiData(volatile unsigned int data) <br />{ <br />  unsigned char Bit = 0;// Bit Counter<br /><br />  LCD_CS_HI();// Makesure CS = Disable<br />  LCD_SCLK_LO();// Standby SCLK <br /><br />  LCD_CS_LO();// Start CS = Enable<br />  LCD_SDATA_HI();  // D/C# = 1(Data)<br />  LCD_SCLK_HI();// Strobe Signal Bit(SDATA)<br />  LCD_SCLK_LO(); // Standby SCLK <br /><br />  for (Bit = 0; Bit &lt; 8; Bit++)// 8 Bit Write<br />  {<br />    LCD_SCLK_LO(); // Standby SCLK <br /><br />if((data&amp;0x80)&gt;&gt;7) <br />{ <br />  LCD_SDATA_HI();  <br />}<br />else<br />{ <br />  LCD_SDATA_LO();<br />}<br /><br />LCD_SCLK_HI();// Strobe Signal Bit(SDATA)<br /><br />data &lt;&lt;= 1; // Next Bit Data<br />  } <br />  LCD_SCLK_LO();// Standby SCLK <br />  LCD_CS_HI();// Stop CS = Disable  <br />}<br /><br />// *****************************************************************************<br />// Backlight.c<br />//<br />// Turns the backlight on and off<br />//<br />// Inputs: state - 1 = backlight on<br />// 2 = backlight off<br />//<br />//<br />// Author: Olimex, James P Lynch July 7, 2007<br />// *****************************************************************************<br />void Backlight(unsigned char state)<br />{<br />  if (state == 1)<br />  {   <br />    LCD_BL_HI();// Black Light ON <br />  }<br />  else<br />  {<br />    LCD_BL_LO();// Black Light OFF <br />  }<br />}<br /><br />// *****************************************************************************<br />// InitLcd.c<br />//<br />// Initializes the Philips PCF8833 LCD Controller<br />//<br />// Inputs: none<br />//<br />// Author: James P Lynch July 7, 2007<br />// *****************************************************************************<br />void InitLcd(void) <br />{<br /><br />/* Konfiguracja  LCD */<br />LCD_DIR_WRITE();  // Config Port Direction<br />LCD_SCLK_LO();   // Standby SCLK<br />LCD_CS_HI();// Disable CS<br />LCD_SDATA_HI();<br /><br />  // Hardware reset<br />  LCD_RESET_LO();// Start Reset  <br />  _delay_ms(200);// Reset Pulse Time<br />  LCD_RESET_HI();// Release Reset<br />  _delay_ms(200);<br /><br />  // Sleep out (command 0x11)<br />  WriteSpiCommand(SLEEPOUT);<br /><br />  // Inversion on (command 0x20)<br />  WriteSpiCommand(INVON); // seems to be required for this controller<br /><br />  // Color Interface Pixel Format (command 0x3A)<br />  WriteSpiCommand(COLMOD);<br />  WriteSpiData(0x3B); // 0x03 = 12 bits-per-pixel<br /><br />  // Memory access controler (command 0x36)<br />  WriteSpiCommand(MADCTL);<br />  WriteSpiData(0x46); // 0xC0 = mirror x and y, reverse rgb<br /><br />  // Write contrast (command 0x25)<br />  WriteSpiCommand(SETCON);<br />  WriteSpiData(0x30); // contrast 0x30<br />  _delay_ms(1000);<br /><br />  // Display On (command 0x29)<br />  WriteSpiCommand(DISPON);<br />}<br /><br />// *****************************************************************************<br />// LCDWrite130x130bmp.c<br />//<br />// Writes the entire screen from a bmp file<br />// Uses Olimex BmpToArray.exe utility<br />//<br />// Inputs: picture in bmp.h<br />//<br />// Author: Olimex, James P Lynch July 7, 2007<br />// *****************************************************************************<br />/*<br />void LCDWrite130x130bmp(void) <br />{<br />  long j; // loop counter<br /><br />  // Memory access controler (command 0x36)<br />  WriteSpiCommand(MADCTL);<br />  WriteSpiData(0x48); // no mirror Y (temporary to satisfy Olimex bmptoarray utility)<br /><br />  // Display OFF<br />  WriteSpiCommand(DISPOFF);<br /><br />  // Column address set (command 0x2A)<br />  WriteSpiCommand(CASET);<br />  WriteSpiData(0);<br />  WriteSpiData(131);<br /><br />  // Page address set (command 0x2B)<br />  WriteSpiCommand(PASET);<br />  WriteSpiData(0);<br />  WriteSpiData(131);<br /><br />  // WRITE MEMORY<br />  WriteSpiCommand(RAMWR);<br />  for (j = 0; j &lt; sizeof(bmp); j++)<br />    {<br />      WriteSpiData(pgm_read_byte(&amp;bmp&#91;j&#93;));<br />    }<br /><br />  // Memory access controler (command 0x36)<br />  WriteSpiCommand(MADCTL);<br />  WriteSpiData(0xc8); // restore to (mirror x and y, reverse rgb)<br /><br />  // Display On<br />  WriteSpiCommand(DISPON);<br />}<br />*/<br />// *****************************************************************************<br />// LCDClearScreen.c<br />//<br />// Clears the LCD screen to single color (BLACK)<br />//<br />// Inputs: none<br />//<br />// Author: James P Lynch July 7, 2007<br />// *****************************************************************************<br />void LCDClearScreen(void) <br />{<br />  long i; // loop counter<br /><br />  // Row address set (command 0x2B)<br />  WriteSpiCommand(PASET);<br />  WriteSpiData(0);<br />  WriteSpiData(131);<br /><br />  // Column address set (command 0x2A)<br />  WriteSpiCommand(CASET);<br />  WriteSpiData(0);<br />  WriteSpiData(131);<br /><br />  // set the display memory to BLACK<br />  WriteSpiCommand(RAMWR);<br />  for (i = 0; i &lt; ((132 * 132) / 2); i++) <br />  {<br />    WriteSpiData((BLACK &gt;&gt; 4) &amp; 0xFF);<br />    WriteSpiData(((BLACK &amp; 0xF) &lt;&lt; 4) | ((BLACK &gt;&gt; 8) &amp; 0xF));<br />    WriteSpiData(BLACK &amp; 0xFF); <br />  }<br />}<br /><br />// *****************************************************************************<br />// LCDSetXY.c<br />//<br />// Sets the Row and Column addresses<br />//<br />// Inputs: x = row address (0 .. 131)<br />// y = column address (0 .. 131)<br />//<br />//<br />// Returns: nothing<br />//<br />// Author: James P Lynch July 7, 2007<br />// *****************************************************************************<br />/*void LCDSetXY(int x, int y)<br />{<br />  // Row address set (command 0x2B)<br />  WriteSpiCommand(PASET);<br />  WriteSpiData(x);<br />  WriteSpiData(x);<br /><br />  // Column address set (command 0x2A)<br />  WriteSpiCommand(CASET);<br />  WriteSpiData(y);<br />  WriteSpiData(y);<br />}<br />*/<br />// *************************************************************************************<br />// LCDSetPixel.c<br />//<br />// Lights a single pixel in the specified color at the specified x and y addresses<br />//<br />// Inputs: x = row address (0 .. 131)<br />// y = column address (0 .. 131)<br />// color = 12-bit color value rrrrggggbbbb<br />// rrrr = 1111 full red<br />// :<br />// 0000 red is off<br />//<br />// gggg = 1111 full green<br />// :<br />// 0000 green is off<br />//<br />// bbbb = 1111 full blue<br />// :<br />// 0000 blue is off<br />//<br />// Returns: nothing<br />//<br />// Note: see lcd.h for some sample color settings<br />//<br />// Author: James P Lynch July 7, 2007<br />// *************************************************************************************<br />/*void LCDSetPixel(int x, int y, int color)<br />{<br />  LCDSetXY(x, y);<br />  WriteSpiCommand(RAMWR);<br />  WriteSpiData((unsigned char)((color &gt;&gt; 4) &amp; 0xFFFF));<br />  WriteSpiData((unsigned char)(((color &amp; 0x0F) &lt;&lt; 4) | 0x00));<br />  WriteSpiCommand(NOP);<br />}<br />*/<br />// *************************************************************************************************<br />// LCDSetLine.c<br />//<br />// Draws a line in the specified color from (x0,y0) to (x1,y1)<br />//<br />// Inputs: x = row address (0 .. 131)<br />// y = column address (0 .. 131)<br />// color = 12-bit color value rrrrggggbbbb<br />// rrrr = 1111 full red<br />// :<br />// 0000 red is off<br />//<br />// gggg = 1111 full green<br />// :<br />// 0000 green is off<br />//<br />// bbbb = 1111 full blue<br />// :<br />// 0000 blue is off<br />//<br />// Returns: nothing<br />//<br />// Note: good write-up on this algorithm in Wikipedia (search for Bresenham's line algorithm)<br />// see lcd.h for some sample color settings<br />//<br />// Authors: Dr. Leonard McMillan, Associate Professor UNC<br />// Jack Bresenham IBM, Winthrop University (Father of this algorithm, 1962)<br />//<br />// Note: taken verbatim from Professor McMillan's presentation:<br />// http://www.cs.unc.edu/~mcmillan/comp136/Lecture6/Lines.html<br />//<br />// *************************************************************************************************<br />/*void LCDSetLine(int x0, int y0, int x1, int y1, int color)<br />{<br />  int dy = y1 - y0;<br />  int dx = x1 - x0;<br />  int stepx, stepy;<br />  if (dy &lt; 0) { dy = -dy; stepy = -1; } else { stepy = 1; }<br />  if (dx &lt; 0) { dx = -dx; stepx = -1; } else { stepx = 1; }<br />  dy &lt;&lt;= 1; // dy is now 2*dy<br />  dx &lt;&lt;= 1; // dx is now 2*dx<br />  LCDSetPixel(x0, y0, color);<br />  if (dx &gt; dy) <br />  {<br />    int fraction = dy - (dx &gt;&gt; 1); // same as 2*dy - dx<br />    while (x0 != x1) <br />    {<br />      if (fraction &gt;= 0) <br />      {<br />        y0 += stepy;<br />        fraction -= dx; // same as fraction -= 2*dx<br />      }<br />      x0 += stepx;<br />      fraction += dy; // same as fraction -= 2*dy<br />      LCDSetPixel(x0, y0, color);<br />    }<br />  } <br />  else <br />  {<br />    int fraction = dx - (dy &gt;&gt; 1);<br />    while (y0 != y1) <br />{<br />      if (fraction &gt;= 0) <br />  {<br />        x0 += stepx;<br />        fraction -= dy;<br />      }<br />      y0 += stepy;<br />      fraction += dx;<br />      LCDSetPixel(x0, y0, color);<br />    }<br />  }<br />}<br />*/<br />// *****************************************************************************************<br />// LCDSetRect.c<br />//<br />// Draws a rectangle in the specified color from (x1,y1) to (x2,y2)<br />// Rectangle can be filled with a color if desired<br />//<br />// Inputs: x = row address (0 .. 131)<br />// y = column address (0 .. 131)<br />// fill = 0=no fill, 1-fill entire rectangle<br />// color = 12-bit color value for lines rrrrggggbbbb<br />// rrrr = 1111 full red<br />// :<br />// 0000 red is off<br />//<br />// gggg = 1111 full green<br />// :<br />// 0000 green is off<br />//<br />// bbbb = 1111 full blue<br />// :<br />// 0000 blue is off<br />// Returns: nothing<br />//<br />// Notes:<br />//<br />// The best way to fill a rectangle is to take advantage of the &quot;wrap-around&quot; featute<br />// built into the Philips PCF8833 controller. By defining a drawing box, the memory can<br />// be simply filled by successive memory writes until all pixels have been illuminated.<br />//<br />// 1. Given the coordinates of two opposing corners (x0, y0) (x1, y1)<br />// calculate the minimums and maximums of the coordinates<br />//<br />// xmin = (x0 &lt;= x1) ? x0 : x1;<br />// xmax = (x0 &gt; x1) ? x0 : x1;<br />// ymin = (y0 &lt;= y1) ? y0 : y1;<br />// ymax = (y0 &gt; y1) ? y0 : y1;<br />//<br />// 2. Now set up the drawing box to be the desired rectangle<br />//<br />// WriteSpiCommand(PASET); // set the row boundaries<br />// WriteSpiData(xmin);<br />// WriteSpiData(xmax);<br />// WriteSpiCommand(CASET); // set the column boundaries<br />// WriteSpiData(ymin);<br />// WriteSpiData(ymax);<br />//<br />// 3. Calculate the number of pixels to be written divided by 2<br />//<br />// NumPixels = ((((xmax - xmin + 1) * (ymax - ymin + 1)) / 2) + 1)<br />//<br />// You may notice that I added one pixel to the formula.<br />// This covers the case where the number of pixels is odd and we<br />// would lose one pixel due to rounding error. In the case of<br />// odd pixels, the number of pixels is exact.<br />// in the case of even pixels, we have one more pixel than<br />// needed, but it cannot be displayed because it is outside<br />// the drawing box.<br />//<br />// We divide by 2 because two pixels are represented by three bytes.<br />// So we work through the rectangle two pixels at a time.<br />//<br />// 4. Now a simple memory write loop will fill the rectangle<br />//<br />// for (i = 0; i &lt; ((((xmax - xmin + 1) * (ymax - ymin + 1)) / 2) + 1); i++) {<br />// WriteSpiData((color &gt;&gt; 4) &amp; 0xFF);<br />// WriteSpiData(((color &amp; 0xF) &lt;&lt; 4) | ((color &gt;&gt; 8) &amp; 0xF));<br />// WriteSpiData(color &amp; 0xFF);<br />// }<br />//<br />// In the case of an unfilled rectangle, drawing four lines with the Bresenham line<br />// drawing algorithm is reasonably efficient.<br />//<br />// Author: James P Lynch July 7, 2007<br />// *****************************************************************************************<br />/*void LCDSetRect(int x0, int y0, int x1, int y1, unsigned char fill, int color)<br />{<br />  int xmin, xmax, ymin, ymax;<br />  int i;<br /><br />  // check if the rectangle is to be filled<br />  if (fill == FILL) <br />  {<br />    // best way to create a filled rectangle is to define a drawing box<br />    // and loop two pixels at a time<br />    // calculate the min and max for x and y directions<br />    xmin = (x0 &lt;= x1) ? x0 : x1;<br />    xmax = (x0 &gt; x1) ? x0 : x1;<br />    ymin = (y0 &lt;= y1) ? y0 : y1;<br />    ymax = (y0 &gt; y1) ? y0 : y1;<br /><br />    // specify the controller drawing box according to those limits<br />    // Row address set (command 0x2B)<br />    WriteSpiCommand(PASET);<br />    WriteSpiData(xmin);<br />    WriteSpiData(xmax);<br /><br />    // Column address set (command 0x2A)<br />    WriteSpiCommand(CASET);<br />    WriteSpiData(ymin);<br />    WriteSpiData(ymax);<br /><br />    // WRITE MEMORY<br />    WriteSpiCommand(RAMWR);<br /><br />    // loop on total number of pixels / 2<br />    for (i = 0; i &lt; ((((xmax - xmin + 1) * (ymax - ymin + 1)) / 2) + 1); i++) <br />{<br />      // use the color value to output three data bytes covering two pixels<br />      WriteSpiData((color &gt;&gt; 4) &amp; 0xFF);<br />      WriteSpiData(((color &amp; 0xF) &lt;&lt; 4) | ((color &gt;&gt; 8) &amp; 0xF));<br />      WriteSpiData(color &amp; 0xFF);<br />    }<br />  } <br />  else <br />  {<br />    // best way to draw un unfilled rectangle is to draw four lines<br />    LCDSetLine(x0, y0, x1, y0, color);<br />    LCDSetLine(x0, y1, x1, y1, color);<br />    LCDSetLine(x0, y0, x0, y1, color);<br />    LCDSetLine(x1, y0, x1, y1, color);<br />  }<br />}<br />*/<br />// *************************************************************************************<br />// LCDSetCircle.c<br />//<br />// Draws a line in the specified color at center (x0,y0) with radius<br />//<br />// Inputs: x0 = row address (0 .. 131)<br />// y0 = column address (0 .. 131)<br />// radius = radius in pixels<br />// color = 12-bit color value rrrrggggbbbb<br />//<br />// Returns: nothing<br />//<br />// Author: Jack Bresenham IBM, Winthrop University (Father of this algorithm, 1962)<br />//<br />// Note: taken verbatim Wikipedia article on Bresenham's line algorithm<br />// http://www.wikipedia.org<br />//<br />// *************************************************************************************<br /><br />/*void LCDSetCircle(int x0, int y0, int radius, int color)<br />{<br />  int f = 1 - radius;<br />  int ddF_x = 0;<br />  int ddF_y = -2 * radius;<br />  int x = 0;<br />  int y = radius;<br />  LCDSetPixel(x0, y0 + radius, color);<br />  LCDSetPixel(x0, y0 - radius, color);<br />  LCDSetPixel(x0 + radius, y0, color);<br />  LCDSetPixel(x0 - radius, y0, color);<br />  while (x &lt; y) <br />  {<br />    if (f &gt;= 0) <br />{<br />      y--;<br />      ddF_y += 2;<br />      f += ddF_y;<br />    }<br />    x++;<br />    ddF_x += 2;<br />    f += ddF_x + 1;<br />    LCDSetPixel(x0 + x, y0 + y, color);<br />    LCDSetPixel(x0 - x, y0 + y, color);<br />    LCDSetPixel(x0 + x, y0 - y, color);<br />    LCDSetPixel(x0 - x, y0 - y, color);<br />    LCDSetPixel(x0 + y, y0 + x, color);<br />    LCDSetPixel(x0 - y, y0 + x, color);<br />    LCDSetPixel(x0 + y, y0 - x, color);<br />    LCDSetPixel(x0 - y, y0 - x, color);<br />   }<br />}<br />*/<br />// *****************************************************************************<br />// LCDPutChar.c<br />//<br />// Draws an ASCII character at the specified (x,y) address and color<br />//<br />// Inputs: c = character to be displayed<br />// x = row address (0 .. 131)<br />// y = column address (0 .. 131)<br />// size = font pitch (SMALL, MEDIUM, LARGE)<br />// fcolor = 12-bit foreground color value rrrrggggbbbb<br />// bcolor = 12-bit background color value rrrrggggbbbb<br />//<br />//<br />// Returns: nothing<br />//<br />//<br />// Notes: Here's an example to display &quot;E&quot; at address (20,20)<br />//<br />// LCDPutChar('E', 20, 20, MEDIUM, WHITE, BLACK);<br />//<br />// (27,20) (27,27)<br />// | |<br />// | |<br />// ^ V V<br />// : _ # # # # # # # 0x7F<br />// : _ _ # # _ _ _ # 0x31<br />// : _ _ # # _ # _ _ 0x34<br />// x _ _ # # # # _ _ 0x3C<br />// : _ _ # # _ # _ _ 0x34<br />// : _ _ # # _ _ _ # 0x31<br />// : _ # # # # # # # 0x7F<br />// : _ _ _ _ _ _ _ _ 0x00<br />//<br />// ------y-------&gt;<br />// ^ ^<br />// | |<br />// | |<br />// (20,20) (20,27)<br />//<br />//<br />// The most efficient way to display a character is to make use of the &quot;wrap-around&quot; feature<br />// of the Philips PCF8833 LCD controller chip.<br />//<br />// Assume that we position the character at (20, 20) that's a (row, col) specification.<br />// With the row and column address set commands, you can specify an 8x8 box for the SMALL and MEDIUM<br />// characters or a 16x8 box for the LARGE characters.<br />//<br />// WriteSpiCommand(PASET); // set the row drawing limits<br />// WriteSpiData(20); //<br />// WriteSpiData(27); // limit rows to (20, 27)<br />//<br />// WriteSpiCommand(CASET); // set the column drawing limits<br />// WriteSpiData(20); //<br />// WriteSpiData(27); // limit columns to (20,27)<br />//<br />// When the algorithm completes col 27, the column address wraps back to 20<br />// At the same time, the row address increases by one (this is done by the controller)<br />//<br />// We walk through each row, two pixels at a time. The purpose is to create three<br />// data bytes representing these two pixels in the following format (as specified by Philips<br />// for RGB 4 : 4 : 4 format (see page 62 of PCF8833 controller manual).<br />//<br />// Data for pixel 0: RRRRGGGGBBBB<br />// Data for Pixel 1: RRRRGGGGBBBB<br />//<br />// WriteSpiCommand(RAMWR); // start a memory write (96 data bytes to follow)<br />//<br />// WriteSpiData(RRRRGGGG); // first pixel, red and green data<br />// WriteSpiData(BBBBRRRR); // first pixel, blue data; second pixel, red data<br />// WriteSpiData(GGGGBBBB); // second pixel, green and blue data<br />// :<br />// and so on until all pixels displayed!<br />// :<br />// WriteSpiCommand(NOP); // this will terminate the RAMWR command<br />//<br />//<br />// Author: James P Lynch July 7, 2007<br />// *****************************************************************************<br />void LCDPutChar(char c, int x, int y, int size, int fColor, int bColor) <br />{<br />  int i,j;<br />  unsigned int  nCols;<br />  unsigned int  nRows;<br />  unsigned int  nBytes;<br /> // unsigned char PixelRow;<br /> // unsigned char Mask;<br />  unsigned int PixelRow;<br />  unsigned int Mask;<br />  unsigned int  Word0;<br />  unsigned int  Word1;<br />  unsigned char *pFont;<br />  unsigned char *pChar;<br />  unsigned char *FontTable&#91;&#93; = <br />  {<br />(unsigned char *)FONT6x8,<br />                                (unsigned char *)FONT8x8,<br />                                (unsigned char *)FONT8x16,<br />                                (unsigned char *)FONT32x16<br />};<br /><br />  // get pointer to the beginning of the selected font table<br />  pFont = (unsigned char *)FontTable&#91;size&#93;;<br /><br />  /* get the nColumns, nRows and nBytes */<br />  //nCols = *pFont;<br />  nCols  = pgm_read_byte(&amp;*pFont);         // Array Flash<br />  //nRows = *(pFont + 1);<br />  nRows  = pgm_read_byte(&amp;*(pFont + 1));   // Array Flash<br />  //nBytes = *(pFont + 2);<br />  nBytes = pgm_read_byte(&amp;*(pFont + 2));   // Array Flash<br /><br />  nBytes = pgm_read_byte(&amp;*(pFont + 3));<br /><br />  /* get pointer to the last byte of the desired character */<br />  pChar = pFont + (nBytes * (c - 0x1F)) + nBytes - 1;<br /><br />  // Row address set (command 0x2B)<br />  WriteSpiCommand(PASET);<br />  WriteSpiData(x);<br />  WriteSpiData(x + nRows - 1);<br /><br />  // Column address set (command 0x2A)<br />  WriteSpiCommand(CASET);<br />  WriteSpiData(y);<br />  WriteSpiData(y + nCols - 1);<br /><br />  // WRITE MEMORY<br />  WriteSpiCommand(RAMWR);<br />  // loop on each row, working backwards from the bottom to the top<br />  for (i = nRows - 1; i &gt;= 0; i--) <br />  {<br />    /* copy pixel row from font table and then decrement row */<br /><br />PixelRow = pgm_read_byte(&amp;*pChar--);  // Array Flash<br />  if(nCols &gt; 8)<br />  PixelRow+= pgm_read_byte(&amp;*pChar--) * 256;<br /><br /><br />    // loop on each pixel in the row (left to right)<br />    // Note: we do two pixels each loop<br />    //Mask = 0x80;<br /> // Mask=1;<br />//  for (k=0;k&lt;nCols-1;k++)<br /> // Mask*=2;<br />  Mask = pow(2,nCols - 1);<br /><br /><br />    for (j = 0; j &lt; nCols; j += 2) <br />{<br />      // if pixel bit set, use foreground color; else use the background color<br />      // now get the pixel color for two successive pixels<br />      if ((PixelRow &amp; Mask) == 0)<br />        Word0 = bColor;<br />      else<br />        Word0 = fColor;<br />      Mask = Mask &gt;&gt; 1;<br /><br />      if ((PixelRow &amp; Mask) == 0)<br />        Word1 = bColor;<br />      else<br />        Word1 = fColor;<br />      Mask = Mask &gt;&gt; 1;<br /><br />      // use this information to output three data bytes<br />      WriteSpiData((Word0 &gt;&gt; 4) &amp; 0xFF);<br />      WriteSpiData(((Word0 &amp; 0xF) &lt;&lt; 4) | ((Word1 &gt;&gt; 8) &amp; 0xF));<br />      WriteSpiData(Word1 &amp; 0xFF);<br />    }<br />  }<br /><br />  // terminate the Write Memory command<br />  WriteSpiCommand(NOP);<br />}<br /><br />// *************************************************************************************************<br />// LCDPutStr.c<br />//<br />// Draws a null-terminates character string at the specified (x,y) address, size and color<br />//<br />// Inputs: pString = pointer to character string to be displayed<br />// x = row address (0 .. 131)<br />// y = column address (0 .. 131)<br />// Size = font pitch (SMALL, MEDIUM, LARGE)<br />// fColor = 12-bit foreground color value rrrrggggbbbb<br />// bColor = 12-bit background color value rrrrggggbbbb<br />//<br />//<br />// Returns: nothing<br />//<br />// Notes: Here's an example to display &quot;Hello World!&quot; at address (20,20)<br />//<br />// LCDPutChar(&quot;Hello World!&quot;, 20, 20, LARGE, WHITE, BLACK);<br />//<br />//<br />// Author: James P Lynch July 7, 2007<br />// *************************************************************************************************<br />void LCDPutStr(char *pString, int x, int y, int Size, int fColor, int bColor) <br />{<br />  // loop until null-terminator is seen<br />  while (*pString != 0x00) <br />  {<br />    // draw the character<br />    LCDPutChar(*pString++, x, y, Size, fColor, bColor);<br /><br />    // advance the y position<br />    if (Size == SMALL)<br />    y = y + 6;<br /><br />    else if (Size == MEDIUM)<br />    y = y + 8;<br /><br />    else<br />    y = y + 8;<br /><br />    // bail out if y exceeds 131<br />    if (y &gt; 131) break;<br />  }<br />}[/syntax]<br /><br />Proszę o pomoc, może ktoś posiada wsad do obsługi większej czcionki dla tego wyświetlacza.<br />Interesuje mnie czcionka tylko dla cyfr, aby wyświetlić temperaturę.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=1890">heniug</a> — 27 kwi 2014, o 21:38</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[xor]]></name></author>
<updated>2014-04-24T08:08:59+01:00</updated>
<published>2014-04-24T08:08:59+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=6866&amp;p=79027#p79027</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=6866&amp;p=79027#p79027"/>
<title type="html"><![CDATA[Re: [Eclipse] Problem z kompilacją]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=6866&amp;p=79027#p79027"><![CDATA[
<a href="http://www.avrfreaks.net/index.php?name=PNphpBB2&amp;file=printview&amp;t=99203&amp;start=0"  class="postlink">http://www.avrfreaks.net/index.php?name=PNphpBB2&amp;file=printview&amp;t=99203&amp;start=0</a><p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=1774">xor</a> — 24 kwi 2014, o 08:08</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[DamCos]]></name></author>
<updated>2014-04-24T07:51:02+01:00</updated>
<published>2014-04-24T07:51:02+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=6866&amp;p=79026#p79026</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=6866&amp;p=79026#p79026"/>
<title type="html"><![CDATA[Re: [Eclipse] Problem z kompilacją]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=6866&amp;p=79026#p79026"><![CDATA[
<div class="quotetitle">heniug napisał(a):</div><div class="quotecontent"><br />Witam<br />W czasie kompilacji mam komunikat:<br /><br /><ul>**** Build of configuration Release for project LCD6100_DS18B20 ****<br /><br />make all <br />Building target: LCD6100_DS18B20.elf<br />Invoking: AVR C Linker<br />avr-gcc -Wl,-Map,LCD6100_DS18B20.map -mmcu=atmega32 -o &quot;LCD6100_DS18B20.elf&quot;  ./LCD6610_NXP.o ./crc8.o ./ds18x20.o ./main.o ./onewire.o   <br />d:/instalacje/avr toolchain/bin/../lib/gcc/avr/4.6.2/../../../../avr/lib/avr5\libc.a(floatsisf.o):/home/tools/hudson/workspace/avr8-gnu-toolchain/src/avr-libc/libm/fplib/floatsisf.S:42: multiple definition of `__floatunsisf'<br />d:/instalacje/avr toolchain/bin/../lib/gcc/avr/4.6.2/avr5\libgcc.a(_usi_to_sf.o):/home/tools/hudson/workspace/avr8-gnu-toolchain/build-win32_x86/avr-gcc-full/avr/avr5/libgcc/../../.././gcc/fp-bit.c:1378: first defined here<br />collect2: ld returned 1 exit status<br />make: *** [LCD6100_DS18B20.elf] Błąd 1<br /><br />**** Build Finished ****</ul><br />jedynie robaczek pojawia się tutaj<br /><br />[syntax=c]// clear undefined bits for B != 12bit<br />if ( fc == DS18B20_ID ) { // check resolution 18B20<br />i = sp&#91;DS18B20_CONF_REG&#93;;<br />if ( (i &amp; DS18B20_12_BIT) == DS18B20_12_BIT );  TUTAJ<br />else if ( (i &amp; DS18B20_11_BIT) == DS18B20_11_BIT )<br />meas &amp;= ~(DS18B20_11_BIT_UNDF);<br />else if ( (i &amp; DS18B20_10_BIT) == DS18B20_10_BIT )<br />meas &amp;= ~(DS18B20_10_BIT_UNDF);<br />else { // if ( (i &amp; DS18B20_9_BIT) == DS18B20_9_BIT ) {<br />meas &amp;= ~(DS18B20_9_BIT_UNDF);<br />}<br />}[/syntax]<br /></div><br /><br />Podaj kod wszystkich powiązanych ze sobą plików.  Z tego co widzę to gdzieś masz kilka razy zdefimiowaną zmienną albo funkcję<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=3947">DamCos</a> — 24 kwi 2014, o 07:51</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[heniug]]></name></author>
<updated>2014-04-23T21:33:13+01:00</updated>
<published>2014-04-23T21:33:13+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=6866&amp;p=79006#p79006</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=6866&amp;p=79006#p79006"/>
<title type="html"><![CDATA[[Eclipse] Problem z kompilacją]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=6866&amp;p=79006#p79006"><![CDATA[
Witam<br />W czasie kompilacji mam komunikat:<br /><br /><ul>**** Build of configuration Release for project LCD6100_DS18B20 ****<br /><br />make all <br />Building target: LCD6100_DS18B20.elf<br />Invoking: AVR C Linker<br />avr-gcc -Wl,-Map,LCD6100_DS18B20.map -mmcu=atmega32 -o &quot;LCD6100_DS18B20.elf&quot;  ./LCD6610_NXP.o ./crc8.o ./ds18x20.o ./main.o ./onewire.o   <br />d:/instalacje/avr toolchain/bin/../lib/gcc/avr/4.6.2/../../../../avr/lib/avr5\libc.a(floatsisf.o):/home/tools/hudson/workspace/avr8-gnu-toolchain/src/avr-libc/libm/fplib/floatsisf.S:42: multiple definition of `__floatunsisf'<br />d:/instalacje/avr toolchain/bin/../lib/gcc/avr/4.6.2/avr5\libgcc.a(_usi_to_sf.o):/home/tools/hudson/workspace/avr8-gnu-toolchain/build-win32_x86/avr-gcc-full/avr/avr5/libgcc/../../.././gcc/fp-bit.c:1378: first defined here<br />collect2: ld returned 1 exit status<br />make: *** [LCD6100_DS18B20.elf] Błąd 1<br /><br />**** Build Finished ****</ul><br />jedynie robaczek pojawia się tutaj<br /><br />[syntax=c]// clear undefined bits for B != 12bit<br />if ( fc == DS18B20_ID ) { // check resolution 18B20<br />i = sp&#91;DS18B20_CONF_REG&#93;;<br />if ( (i &amp; DS18B20_12_BIT) == DS18B20_12_BIT );  TUTAJ<br />else if ( (i &amp; DS18B20_11_BIT) == DS18B20_11_BIT )<br />meas &amp;= ~(DS18B20_11_BIT_UNDF);<br />else if ( (i &amp; DS18B20_10_BIT) == DS18B20_10_BIT )<br />meas &amp;= ~(DS18B20_10_BIT_UNDF);<br />else { // if ( (i &amp; DS18B20_9_BIT) == DS18B20_9_BIT ) {<br />meas &amp;= ~(DS18B20_9_BIT_UNDF);<br />}<br />}[/syntax]<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=1890">heniug</a> — 23 kwi 2014, o 21:33</p><hr />
]]></content>
</entry>
</feed>