2011年8月28日星期日

新奥尔良烤翅

材料:10个鸡翅、蜂蜜、酱油、盐、料酒(红酒也可)、姜、红干辣椒、五香粉、黑胡椒。 作法:
  1.如果是速冻鸡翅,请先解冻。把10个新鲜鸡翅放在一个可在微波炉内加热的器皿内。
  2.加入少量酱油,放2勺酱油足可。
  3.加入料酒或红酒,大约2勺子,主要用于去掉鸡翅的腥味。
  4.加入盐、少许姜沫、少许辣椒子,少许五香粉(一般超市都有卖)、少许黑胡椒。
  5.将鸡翅和作料搅拌均匀,充分粘取作料。
  6.盖好盖子将鸡翅放在冰箱冷藏室腌制,电视上讲最好是一宿(所以一定要提前准备,不能现吃现做。如果实在很急,也要腌制2-3个小时,充分进味儿)。
  7.将腌制好的鸡翅取出,涂抹上蜂蜜(这样色泽味道才对!)可根据口味适当增加蜂蜜涂抹的多少。
  8.将涂抹好蜂蜜的鸡翅放进微波炉,中高火加热(一般是3个火苗那档)11分钟即可
编辑本段
爱心提示

  1. 最好不要增加水的添加比例,以免影响烤肉的口味质量。 2.烤箱或微波炉设备不同,烤肉的时间也不完全相同,请在第一次烤肉时注意观察烤肉变化,避免烤糊或烤干。
  3.如果配料开袋后一次没有使用完毕,请密封口放在阴凉干燥处保存,以免失去风味.
  4.腌好的肉如果没有用完,可以包装好放在冰箱内速冻存放,下次解冻后即可直接烤制.
  (聪明人们/懒人们一般都是一次腌很多,存放起来,下次解冻后很快就可以烤了..)

2011年8月21日星期日

炝拌土豆丝

材料:

长型土豆2颗、胡萝卜少量、香菜少量、花椒10颗、干红椒10颗、沙拉油适量

调味料:

盐1/3小匙、鸡精1/4小匙、香醋2小匙、砂糖1小匙、芝麻香油1小匙

做法:

1.将土豆去皮,先切成薄片,再切成细丝。(图1)将切好的细丝用清水洗去表面的淀粉质(图2)

2.锅内烧开水,放入土豆丝和少量胡萝卜丝,氽烫1分钟捞起,(图3)用水冲凉后,浸泡入凉开水中(图4)

3.将放凉的土豆丝彻底沥干水份(图5)将土豆丝放入盆内,放入盐,鸡精,醋,糖,芝麻香油,香菜碎,不要拌放着备用。(图6)

4.锅内放入1大匙沙拉油,冷油放入花椒粒炒至出香味,捞起香椒粒,熄火让油温降至3成热。(图7)

5.再放入干椒段,用小火炒出香味,但不要炒焦了。(图8),乘热将热油和红椒淋在土豆丝上,并加盖焖上1分钟,再拌匀即可食用(图9)

2011年8月7日星期日

When your project grows bigger

From:http://www.embedds.com/when-your-project-grows-bigger/

Until now we used pretty simple program examples where all code fit in to single file and didn’t look very complicated. Probably because we programmed one simple function at a time. We didn’t care much about programming styles and modularizing. But due time, programs are going to grow bigger and more complex. It may become very hard maintain your own code and even harder for other developers to read. We should follow some simple rules that makes microcontroller programming more fun than scratching along.

Split your programs


Say you are writing pretty complex program which deals with LCD, USART and even more peripherals. To make them all work, you need routines to init , read, write, change mode. Imagine how many functions your single file would have to hold and I am not talking about main routine. It would end up with more scrolling than coding. So, smart solution is to split your project in to several files – libraries. Each library would have to take care of one type tasks like controlling USART, other LCD and so on. For instance, our program needs these functions:
-----------------------------------------------
int main();
void MainPortInit();
uint8_t MainReadPort();
void USARTInit();
void USARTSendByte(uint8_t Data);
uint8_t USARTReceiveByte();
void LCDInit();
void LCDclr();
void LCDGotoXY(uint8_t, uint8_t);
void LCDSendChar(uint8_t);
-----------------------------------------------
Putting all these functions in one file would work, but code would become heavy, hard to read and reuse. So lets split all these routines by assigning some logic. Logic basically relies on related functions like USART functions would go to one group, LCD to another. Some general functions may stay in main code. After grouping our example we have three groups of functions that goes to separate files:
-----------------------------------------------
main.c

int main();

void MainPortInit(void);

uint8_t MainReadPort(void);
usart.c
-----------------------------------------------

void USARTInit(void);

void USARTSendByte(uint8_t Data);

uint8_t USARTReceiveByte(void);
lcd.c
-----------------------------------------------

void LCDInit(void);

void LCDclr(void);

void LCDGotoXY(uint8_t, uint8_t);

void LCDSendChar(uint8_t);
After this operation we end up with three source files. But how to link them in to single program. This is done by using header files. So we need to create a pair file to each source file.

main.c – main.h(not required)

usart.c – usart.h;

lcd.c – lcd.h

Header files must be same name as source files but with extension .h. So when one source file needs to use routine from another source file, you must include a header file by defining header file using quotes:
-----------------------------------------------

#include"main.h"

#include"usart.h"

#include"lcd.h"
We already include some headers in our programs but in side brackets, meaning that these are system header files located in system directories.
-----------------------------------------------
#include

#include
Last thing to do is to make header files work. Header file is wrapped around preprocessor defines so called header guard:
-----------------------------------------------
#ifndef LCD_H

#define LCD_H

//contents

#endif
This prevents from multiple includes of same header. First it checks if this file has been included, if not then current is included. The current situation may occur when several source files use same include or include each other. For instance usart.c would include lcd.h and lcd.c would include usart.h – this would lead to recursive inclusion during compilation. So don’t worry to much and use preprocessor defines. Header guard has to be named with all caps. Better use same name as file with underscore instead dot like LCD_H. In order to make header function we need to put something in it. First of all header must have all function prototypes from c file included. For instance lcd.h may look like:
-----------------------------------------------
#ifndef LCD_H

#define LCD_H

//is 4 bit mode?

#define 4BIT

void LCDInit(void);

void LCDclr(void);

void LCDGotoXY(uint8_t, uint8_t);

void LCDSendChar(uint8_t);

#endif
Also there can be various definitions, type definitions or macro functions.

External globals
Also header files can declare global variables that might be used in multiple source files. To make it possible declare variable inside c file:
-----------------------------------------------
uint8_t Mode = 1;
Then in header file lcd.h define this variable by adding “extern” keyword.
-----------------------------------------------
extern uint8_t Mode;
This will make this variable visible in other c files if header is included. Just be sure not to define variables in header files – do this in c file.

Static functions
Last thing to mention about modularizing code is “static” functions. Lets say we created separate lcd.c and lcd.h files. We wrote a bunch of routines like LCDsendCommand(uint8_t), LCDInit(), LCDWrite(uint8_t), LCDGotoXY(uint8_t, uint8_t), and so on. Some of these functions definitely will be used in other files, but some not. For instance LCDsendCommand(uint8_t) will be used only inside lcd.c to make other routines work. We don’t need this function to be accessible by other c files. To do so we add keyword “static” to this function.
-----------------------------------------------
static void LCDsendCommand(uint8_t);
Add this keyword in both – c and h files. This is useful practice that helps compiler to optimize function as it doesn’t have to be called outside the own c file.

Benefits of modularizing
It may seem complicated at the beginning but it is really easy and makes programming smooth. It is good practice to write separate libraries for separate function groups like USART, LCD, ADC, TWI, because once written you can include these libraries multiple times in different projects– just be smart and write them to be more universal – don’t tie to specific hardware, but use preprocessor defines for hardware specific stuff. Later you will see that programming microcontrollers may be same as using/adapting right code library with minimal coding efforts.

Again this is only a scope of few things. We are not going back to them as these are basics of C programming and can be found on every corner in internet where “C tutorial” is mentioned. Better lets focus on microcontroller stuff again.

2011年8月2日星期二

修改Windows XP的登录背景色和图案

1修改Windows XP的登录背景图案:面对长久不变的单调的登录图案,你可能日久生厌,我们可以通过注册表来把它换成自己喜欢的图案,步骤如下:打开注册表编辑器,找到HKEY_USERS\.DEFAULT\Control Panel\Desktop子键分支,双击wallpaper,键入你选择好的图片的路径,如:c:\Documents and Settings\My Documents\My Pictures\mypic.bmp,点击“确定”,然后找到Tilewallpaper,双击它输入键值“1”,重新启动系统即可看到效果。

2修改登录时的背景色:如果你还想修改登录时的背景颜色,可以按以下步骤操作:打开注册表编辑器,找到HKEY_USERS\.DEFAULT\Control Panel\Colors子键分支,双击子键分支下的Background键值名,出现“编辑字符串”对话框,在“数值数据”文本框中输入代表颜色的键值(比如黑色的RGB值为000,白色的RGB值为255 255 255,系统默认值是58 110 165),点击“确定”按钮,重新启动系统即可。

3设置启动信息或增加警告信息:如果在启动Windows XP时,希望显示一些自己定义的个性化信息,可以按以下步骤来操作:打开注册表编辑器,找到KEY_LOCAL_MACHINE_SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon子键分支,双击在它下面的LegalNoticeCaption健值名称,打开“编辑字符串”窗口,在“数值数据”文本框中输入信息对话框的标题,比如“你好,欢迎使用本机器”,然后双击LegalNoticeText,在随后出现的“编辑字符串”窗口中输入想要显示的警告信息,比如“请不要随意修改本级的设置,谢谢!”,单击“确定”按钮,重新启动即可看到修改后的效果了。