2017年4月30日星期日

安装wine


  1. sudo dpkg --add-architecture i386
  2. get key https://dl.winehq.org/wine-builds/Release.key
  3. install key sudo apt-key add Release.key
  4. 添加 sudo apt-add-repository 'deb https://dl.winehq.org/wine-builds/ubuntu/ xenial main'(mint)
  5. sudo apt update
  6. sudo apt install --install-recommends winehq-devel

安装google-chrome


  1. 下载key https://dl-ssl.google.com/linux/linux_signing_key.pub
  2. 安装key sudo apt-key add keyname
  3. 添加源 sudo apt-add-repository 'deb http://dl.google.com/linux/chrome/deb/ stable main'(mint)
  4. sudo apt update
  5. sudo apt install google-chrome-stable

2017年4月25日星期二

Linux Mint 安装后的二三事

最近使用的Ubuntu16.04经常报错,又不想花时间去解决,又因最近一次Gnome的安装,系统无法进入桌面,一气之下安装了Mint,总结如下
  1. 系统安装不再叙述;
  2. 输入法
  • 安装fcitx fcitx-table-wbpy qt4-qtconfig fcitx-frontend-qt4 kde-config-fcitx fcitx-ui-classic
  • 使用im-config配置输入法
  • 使用fcitx-config配置输入法
  • 使用qt4 settings配置输入法
  1.  安装shadowsockets-qt5
  • sudo add-apt-repository ppa:hzwhuang/ss-qt5
  • sudo apt update
  • sudo apt install shadowsocks-qt5
  1. 设置tmpfs
  • 设置虚拟盘, 修改/etc/fstab 此方案不可行
  • 参见https://forums.linuxmint.com/viewtopic.php?t=237543
  • sudo cp /usr/share/systemd/tmp.mount /etc/systemd/system/
  • sudo systemctl enable tmp.mount
  • Reboot

Ubuntu tmpfs配置

Ubuntu tmpfs配置
配置文件位于/lib/init/fstab, 用户在/etc/fstab下的配置将覆盖其配置内容, 下面是配置文件的说明.
# /lib/init/fstab: static file system information.
# These are the filesystems that are always mounted on boot, you can
# override any of these by copying the appropriate line from this file into
# /etc/fstab and tweaking it as you see fit.  See fstab(5).

优化SSD
添加noatime,nodiratime,commit=60参数到mount
创建/tmp tmpfs文件系统到内存
tmpfs /tmp tmpfs defaults,noatime,nodiratime,mode=1777,size=50% 0 0

2017年3月16日星期四

ESP8266 arduino库的一些学习

http://esp8266.github.io/Arduino/versions/2.3.0/doc/reference.html

  1. Digital IO 兼容arduino pinMode, digitalRead, digitalWrite. 状态可为INPUT, OUTPUT, INPUT_PULLUP. 16脚可以设置为为INPUT, OUTPUT, INPUT_PULLDOWN. 启动时所有的引脚默认配置是INPUT.
  2.  GPIO6-11脚不能使用, 原因是因为模块内部, 引脚连接到了SPI Flash芯片上,  如果是QIO模式,会使用6-11脚, DIO模式, 可以使用9和11. 
  3. 支持attachInterrupt, detachInterrupt引脚中断,除了16脚, 中断可以使用所有的其它引脚,中断类型支持CHANGE, RISING, FALLING.
  4. Analog input, 可读入模块电源电压, 或ADC电压, 电压范围是0-1.0V, 如果使用ESP.getVcc()读取VCC电压,则ADC脚不能有接线, 另外ADC_MODE(ADC_VCC);要写在程序中, 最好是在函数外, #include后边.
  5. Analog output analogWrite(pin, value), 用来将引脚做为PWM输出, 数值可为0-PWMRANGE, 0可关断PWM, 默认PWMRANGE=1023, 可以使用analogWriteRange(new_range)改变.
  6. Timing and delays millis(), micros(), 分别显示reset后的毫秒和微秒. delay(ms)暂停程序但wifi和tcpip仍然工作, delayMicroseconds(us)暂停程序微秒. 当wifi连接后, 有大量的代码需要在程序后台运行, wifi和tcp/ip库在每次loop()完成后, 有机会控制一些挂起的事件或运行delay(),  如果你的loop()程序没有调用delay()而使用的时间超过了50ms, 你可能需要增加调用delay()来保证wifi堆栈工作正常. 这里有个yield()等于delay(0), delayMicroseconds(),如果超过20毫秒不推荐使用.
  7. Serial 使用与arduino相同, 使用gpio1(tx), gpio3(rx). 也可以调用Serial.begin()后使用Serial.swap重新映射到gpio15(tx), gpio13(rx),再次调用Serial.swap后恢复gpio1与gpio3. Serial1 使用gpio(tx), 但是无法接收数据, 因为RX脚被用于闪存芯片连接,可能使用用Serial1.begin()调用. 如果serial1没有使用并且serial没有交换, 在调用Serial.begin后,调用Serial.set_tx(2)可以将gpio映射为UART0的tx, 或直接调用Serial.begin(baud, config, mode,2). 默认当你调用Serial.begin后, wifi库的诊断输出是关闭的. 为了重新打开debug输出, 调用Serial.setDebugOutput(true), 如果用serial1输出debug, 调用Serial1.setDebugOut(true). 你仍然需要使用Serial.setDebugOutput(true)来打开printf()功能. Serial与Serial1支持5,6,7,8数据位, odd(o), even(E), no parity(N), 1或2停止位, 你可以使用Serial.begin(baudrate, SERIAL_8N1), Serial.begin(baudrate, Serial_6E2)等来设置你所希望的串口方式. Serial[1].baudRate(), 可以获取端口速率
  8. Progmem 程序中的字符都会占用内存空间, 最好的办法是使用宏与FPSTR(),这里有一个举例
String response1; 
response1 += F("http:"); 
... 
String response2; 
response2 += F("http:");

const char HTTP[] PROGMEM = "http:"; 
... 
{ String response1; 
 response1 += FPSTR(HTTP); 
 ... String response2; 
 response2 += FPSTR(HTTP); 
}

http://esp8266.github.io/Arduino/versions/2.3.0/doc/libraries.html


2017年3月15日星期三

C语言学习-运算符与表达式

运算符和表达式
单目运算符
+
-
++
--
双目运算符
+
_

/
% 取余
关系运算符
>
>=
<
<=
==
!=
逻辑运算符
&&与
||或
!非
赋值运算符
=
x+=8 x=x+8
条件运算符
? 表达式1?表达式2:表达式3 表达式1为真取表达式2,为假取表达式3
逗号运算符
表达式1,表达式2,表达式n x=(a=1),(b=2),(a+b); 最后x=3

C语言学习-数据类型

数据类型
整型
int -32768-+32768
short -32768-+32768
long -2^16-2^16-1
unsigned int 0-65535
unsigned shore -2^16-2^16-1
unsigned long 0-2^32-1
浮点型
float 6-7
double 15-16
long double 18-19
字符型
char