PIXCIR_algorithm.h

/*******************************************/
/*    PIXCIR AG, Switzerland         */
/*******************************************/

//#include "compilation_definitions.h"


/*** Compiler options ***/

//#define AVR_gcc // ATMEL
#define NC30  // RENESAS


/*** protocol option ***/

#define PIXCIR_I2C
//#define AUO_I2C
#define BUTTONS
#define F48

//
//            Max number of electrodes
//

#ifdef F48

 #define XMAX  48
 #define YMAX  48
 
#else // F32 or S32

 #define XMAX  32
 #define YMAX  32

#endif


//
//     EEPROM allocation
//

typedef struct
{
 unsigned char table[XMAX];

#ifdef NC30

 int           nbr;
 unsigned int  reserved;

#else // AVR_gcc

 int           offset[32];

#endif

#ifdef F48

 unsigned int  stamp[6];
 
#else // F32 or S32

 unsigned int  stamp[4];

#endif
 
 unsigned char sensitivity[XMAX];
 unsigned int  setup;
 unsigned char thr;
}
electrode_t;


typedef struct
{
 unsigned char M0_spi;
 unsigned char M1_spi;  
 unsigned char scan_en;
 unsigned char version[4];
 int      X_res; 
 int      Y_res; 
 unsigned char move_thr;
 unsigned char ghost_thr;
 unsigned char fast;
 unsigned char special_borders;
 unsigned char Z_thr;
 unsigned char power_mode;
 unsigned char INT_mode;
 unsigned char INT_width;
 unsigned char drift_comp;
 unsigned char subversion;
 unsigned char noise_thr;
 unsigned char noise_delay;
 unsigned char noise_mode;
 
#ifdef NC30

 unsigned char I2C_timeout;   
 unsigned char I2C_timeout_period;
 unsigned char interval;
 
//!!!!!!!!!!!!!!!!!!!!!!! BYTE ADDED !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

 unsigned char extra_offset;

//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
 unsigned char extra_offset_flag;
 signed char   extra_offset_out[4];
 signed char   extra_offset_in[4];
 unsigned char raw1_delta_offset;
 unsigned char raw2_delta_offset;
 unsigned char M1_calibr;

#ifdef BUTTONS

 unsigned char button_scan;
 unsigned char button_axis;
 int     button_setup_command;
 unsigned char button_nbr;
 unsigned char button_spi_speed;
 unsigned char button_thr_press;
 unsigned char button_thr_release;

#ifdef F48

 unsigned char custom[201];
 
#else // F32 or S32

 unsigned char custom[273];

#endif

#else // NO BUTTONS

#ifdef F48

 unsigned char custom[209];
 
#else // F32 or S32

 unsigned char custom[281];

#endif

#endif

#else // AVR_gcc

// int           offset_M1[30];
// signed char   border_M1_Y[13][2];
 signed char   border_M1_X[20][6];
 unsigned char I2C_timeout;   // I2C time-out disabled if 0, enabled if 1 or 2   
 unsigned char I2C_timeout_period; // I2C time-out period = (I2C_timeout_period * 8.192) ms
 unsigned char interval;
 unsigned char extra_offset_flag;
 signed char   extra_offset_out[4];
 signed char   extra_offset_in[4];
 unsigned char raw1_delta_offset;
 unsigned char raw2_delta_offset;
// unsigned char M1_calibr;

#ifdef BUTTONS

 unsigned char button_scan;
 unsigned char button_axis;
 int     button_setup_command;
 unsigned char button_nbr;
 unsigned char button_spi_speed;
 unsigned char button_thr_press;
 unsigned char button_thr_release;

 unsigned char custom[35];

#else

 unsigned char custom[43];

#endif

#endif

 unsigned char bootlock;  // #511 from start of eeprom structure (pinmap)
}
ee_options_t;


typedef struct
{
 char    disto[32];
 electrode_t  x;
 electrode_t  y;
 ee_options_t options;
}
eeprom_t;


#ifdef NC30

/
//  ME0 offsets are stored in data Flash Block B
/

#define offset_x   0x3400
#define offset_y  (offset_x + ((XMAX-1)*2))

/*
typedef struct
{
    int x[31];
 int y[31];
}
offset_t;
*/

/
//  ME1 offsets are stored in data Flash Block C
/

#define offset_M1  0x3800

#endif


//
//     RAM allocation
//

/****************************************************************************************************************************/
/*************************************   AUO I2C protocol   *************************************************/
/****************************************************************************************************************************/

#ifdef AUO_I2C

#define WAKE_UP_BUFFER_SIZE 16

typedef struct
{
 int posx;           // 1st finger
 int posy;   

 int posx2;    // 2nd finger   
 int posy2;
}
shadow_t;

typedef struct
{
 //
 // READ ONLY  MEMBERS
 //
 // PIXCIR_algorithm () will write to these members
 //

 int posx;            // 1st finger position
 int posy;   

 int posx2;    // 2nd finger position 
 int posy2;
 
// int reserved_1[6];  // Customer reserved space

/*
 int raw1;    // Customer reserved space used as debug variables
 int raw2; 
 int raw3;
 int raw4; 
 int raw5; 
 int raw6;
*/

// address +8
 unsigned char cross_enable;  // Customer reserved space used as crossnode function variables
 unsigned char cross_x;
 unsigned char cross_y;
 int crossing;

// address +13
 unsigned char internal_enable; // Customer reserved space used as internal algorithm check variables
 int x_signal;    
 int y_signal;
 
// address +18
 unsigned char noise_mode; 
 unsigned char noise_level;
// unsigned char reserved_1[2]; // Customer reserved space

 unsigned char X1_W;    // Touch areas of each coordinates
 unsigned char Y1_W;
 unsigned char X2_W;
 unsigned char Y2_W;

// address +24
 int initial_distance;
 int distance;
 int ratio;
// unsigned char reserved_2[6]; // Customer reserved space

 unsigned char X1_Z;    // Finger to panel distance of each coordinates
 unsigned char Y1_Z;
 unsigned char X2_Z;
 unsigned char Y2_Z;

// address +34
// unsigned char synch;   // Synchronization on LCM Vcom signal
// unsigned char reserved_3[8];

// int stack_count;    // Monitors the remaining space between the top of the stack and the bottom of global data section
// unsigned char reserved_3[7];

 unsigned char reserved_3[9]; // Customer reserved space

 //
 // AUO PARAMETERS
 //
 //  PIXCIR_algorithm () will read from or write to
 //  these members at each iteration.
 //
 
 int xy_raw1[31];    // AUO channels, first part

 unsigned char reserved_4;
   
// address +106
    unsigned char subversion;

 unsigned char reserved_5[4]; // Customer reserved space

 unsigned char xthr;      // Threshold for X axis (low => more sensitive)
  
 unsigned char ythr;      // same for Y electrodes

 unsigned char INT_mode;   // Interrupt mode

 unsigned char INT_width;  // Interrupt pulse width

 unsigned char power_mode;    // Power mode

 unsigned char version[4];  // Firmware version
 
// address +120
 unsigned char specop;    // Special operation (addr +120 from beginning of RAM table)
 
 unsigned int EEPROM_read_addr;  // Start address of the EEPROM read operation

// address +123
 unsigned int crc;      // CRC checksum of whole program memory

 unsigned char reserved_6[3]; // Customer reserved space

// address +128
 int xy_raw2[31];    // AUO channels, second part

// address +190
 unsigned char interval;

 unsigned char buffer_level;

 int buffer[2*WAKE_UP_BUFFER_SIZE];

 //
 // PIXCIR PARAMETERS
 //
 //  PIXCIR_algorithm () will read from or write to
 //  these members at each iteration.
 //

// address +256
 unsigned char M0_spi;     // Method 0 Sensing speed (SPI data rate)
           // high nibble for X, low nibble for Y
         // high/low pulse width = ((3*k)+2)/8 us
           // 2 -> SPI CLK = 500 kHz
           // 5 -> SPI CLK = 235 kHz
         // A -> SPI CLK = 125 kHz
         // F -> SPI CLK =  85 kHz

 unsigned char M1_spi;     // Method 1 Sensing speed (SPI data rate)
         // high/low pulse width = ((3*k)+2)/8 us
           // 2 -> SPI CLK = 500 kHz
           // 5 -> SPI CLK = 235 kHz
         // A -> SPI CLK = 125 kHz
         // F -> SPI CLK =  85 kHz

 unsigned int strength;   // Signal strength estimation
 
 unsigned char touching;   // Number of fingers on the panel
 
 unsigned char old_touching;   // Previous scan number of fingers on the panel
 
 unsigned char offset;    // Autozero from EEPROM is done if cleared

 int xxraw[XMAX-1+2];     // PIXCIR X raw data

 int yyraw[YMAX-1+2];     // PIXCIR Y raw data

#ifdef AVR_gcc

} __attribute__((packed))
position_t;

#else

}
position_t;

#endif

#endif


/****************************************************************************************************************************/
/*************************************   PIXCIR I2C protocol   *************************************************/
/****************************************************************************************************************************/

#ifdef PIXCIR_I2C

#ifdef NC30

 #define WAKE_UP_BUFFER_SIZE  16

#else // AVR_gcc

 #define WAKE_UP_BUFFER_SIZE  8

#endif

typedef struct
{
 unsigned char touching;         // Number of fingers on the panel
 unsigned char old_touching;  // Previous scan number of fingers on the panel

 int posx;              // 1st finger
 int posy;   

 int posx2;      // 2nd finger   
 int posy2;

 unsigned char X1_W;    // Touch areas of each coordinates
 unsigned char Y1_W;
 unsigned char X2_W;
 unsigned char Y2_W;

 unsigned char X1_Z;    // Finger to panel distance of each coordinates
 unsigned char Y1_Z;
 unsigned char X2_Z;
 unsigned char Y2_Z;
}
shadow_t;

typedef struct
{
// ----------------------------------------------------------------------------------------------
//           Shadow protected
// ----------------------------------------------------------------------------------------------

    unsigned char touching;         // Number of fingers on the panel
    unsigned char old_touching;  // Previous scan number of fingers on the panel

    int posx;              // 1st finger position
    int posy;
   
    int posx2;      // 2nd finger position 
    int posy2;
  
    unsigned char X1_W;    // Touch areas of each coordinates
    unsigned char Y1_W;
    unsigned char X2_W;
    unsigned char Y2_W;

    unsigned char X1_Z;    // Finger to panel distance of each coordinates
    unsigned char Y1_Z;
    unsigned char X2_Z;
    unsigned char Y2_Z;

// ----------------------------------------------------------------------------------------------
//          End of shadow protection
// ----------------------------------------------------------------------------------------------

 unsigned int strength;   // Signal strength estimation

 unsigned char power_mode;    // Power mode
 unsigned char INT_mode;   // Interrupt mode
 unsigned char INT_width;  // Interrupt pulse width

 unsigned char noise_mode; 
    unsigned char noise_thr;
    unsigned char noise_level;

#ifdef BUTTONS

 char reserved_1[15];

// address +41
 char button_flags;

#else

 char reserved_1[16];

// char reserved_1[14];

// address +40
// int stack_count;    // Monitors the remaining space between the max top of the stack and the bottom of global data section

#endif

// address +42
 int initial_distance;
 int distance;
 int ratio;

    unsigned char version[4];  // Firmware version
    unsigned char subversion;
    unsigned int crc;      // CRC checksum of whole program memory

 unsigned char specop;    // Special operation
 unsigned int EEPROM_read_addr;  // Start address of the EEPROM read operation

 unsigned char xthr;      // Threshold for X axis. Low => more sensible
 unsigned char ythr;      // same for Y electrodes

 unsigned char synch;   // Synchronization on LCM Vcom signal

// ----------------------------------------------------------------------------------------------
//       PRIVILEGE 1 (necessary for production testing)
// ----------------------------------------------------------------------------------------------

#ifdef F48

    int xy_raw1[XMAX-1];   // Customer channels, first part
    int xy_raw2[XMAX-1];   // Customer channels, second part. Used for buttons RAW

#else

 int xy_raw1[32];    // Customer channels, first part
    int xy_raw2[32];    // Customer channels, second part. Used for buttons RAW
 
#endif

    unsigned char cross_enable;  // crossnode function variables
    unsigned char cross_x;
    unsigned char cross_y;
    int crossing;

    unsigned char internal_enable; // internal algorithm check variables
    int x_signal;     
    int y_signal;

 unsigned char interval;   // Wake-up buffer variables
 unsigned char buffer_level;
 int buffer[2*WAKE_UP_BUFFER_SIZE];

// ----------------------------------------------------------------------------------------------
//         PRIVILEGE 2 (Private to PIXCIR)
// ----------------------------------------------------------------------------------------------

    unsigned char offset;    // Autozero from EEPROM is done if cleared

    unsigned char M0_spi;     // Method 0 Sensing speed (SPI data rate)
           // high nibble for X, low nibble for Y
         // high/low pulse width = ((3*k)+2)/8 us
           // 2 -> SPI CLK = 500 kHz
           // 5 -> SPI CLK = 235 kHz
         // A -> SPI CLK = 125 kHz
         // F -> SPI CLK =  85 kHz

 unsigned char M1_spi;     // Method 1 Sensing speed (SPI data rate)
         // high/low pulse width = ((3*k)+2)/8 us
           // 2 -> SPI CLK = 500 kHz
           // 5 -> SPI CLK = 235 kHz
         // A -> SPI CLK = 125 kHz
         // F -> SPI CLK =  85 kHz

 int xxraw[XMAX-1+2];     // PIXCIR X raw data
 int yyraw[YMAX-1+2];     // PIXCIR Y raw data

#ifdef BUTTONS

 int button_raw_max[8];

#endif

#ifdef AVR_gcc

} __attribute__((packed))
position_t;

#else

}
position_t;

#endif

#endif


/****************************************************************************************************************************/
/*****************************   drift compensation filter structure   *****************************************/
/****************************************************************************************************************************/

typedef struct
{
 long filter_content[4];
 int  real_previous_raw[4];
}
calib_s;


/****************************************************************************************************************************/
/*************************************   functions headers   *************************************************/
/****************************************************************************************************************************/

char PIXCIR_algorithm (void);

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
ava实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),可运行高分资源 Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现的毕业设计&&课程设计(包含运行文档+数据库+前后端代码),Java实现
C语言是一种广泛使用的编程语言,它具有高效、灵活、可移植性强等特点,被广泛应用于操作系统、嵌入式系统、数据库、编译器等领域的开发。C语言的基本语法包括变量、数据类型、运算符、控制结构(如if语句、循环语句等)、函数、指针等。下面详细介绍C语言的基本概念和语法。 1. 变量和数据类型 在C语言中,变量用于存储数据,数据类型用于定义变量的类型和范围。C语言支持多种数据类型,包括基本数据类型(如int、float、char等)和复合数据类型(如结构体、联合等)。 2. 运算符 C语言中常用的运算符包括算术运算符(如+、、、/等)、关系运算符(如==、!=、、=、<、<=等)、逻辑运算符(如&&、||、!等)。此外,还有位运算符(如&、|、^等)和指针运算符(如、等)。 3. 控制结构 C语言中常用的控制结构包括if语句、循环语句(如for、while等)和switch语句。通过这些控制结构,可以实现程序的分支、循环和多路选择等功能。 4. 函数 函数是C语言中用于封装代码的单元,可以实现代码的复用和模块化。C语言中定义函数使用关键字“void”或返回值类型(如int、float等),并通过“{”和“}”括起来的代码块来实现函数的功能。 5. 指针 指针是C语言中用于存储变量地址的变量。通过指针,可以实现对内存的间接访问和修改。C语言中定义指针使用星号()符号,指向数组、字符串和结构体等数据结构时,还需要注意数组名和字符串常量的特殊性质。 6. 数组和字符串 数组是C语言中用于存储同类型数据的结构,可以通过索引访问和修改数组中的元素。字符串是C语言中用于存储文本数据的特殊类型,通常以字符串常量的形式出现,用双引号("...")括起来,末尾自动添加'\0'字符。 7. 结构体和联合 结构体和联合是C语言中用于存储不同类型数据的复合数据类型。结构体由多个成员组成,每个成员可以是不同的数据类型;联合由多个变量组成,它们共用同一块内存空间。通过结构体和联合,可以实现数据的封装和抽象。 8. 文件操作 C语言中通过文件操作函数(如fopen、fclose、fread、fwrite等)实现对文件的读写操作。文件操作函数通常返回文件指针,用于表示打开的文件。通过文件指针,可以进行文件的定位、读写等操作。 总之,C语言是一种功能强大、灵活高效的编程语言,广泛应用于各种领域。掌握C语言的基本语法和数据结构,可以为编程学习和实践打下坚实的基础。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值