鳕鱼天空

This is Mr Wang's Tech Blog.

Ardino节电模式、自动休眠、按钮打开和关闭

#include <avr/sleep.h>
#include <avr/power.h>
//#include <avr/wdt.h>

#include <MsTimer2.h>

int pin = 13;

volatile int f_sleepButton = 0;
volatile int f_sleepTimer = 0;

void setup() {
  //Serial.begin(9600);
  //Serial.print("Welcome to use!\n");
  pinMode(pin, OUTPUT);
  pinMode(2, INPUT);

  MsTimer2::set(2000, sleepTimer);        // 中断设置函数,每 2000ms 进入一次中断
  MsTimer2::start();

  sleepNow();
}

void loop() {
  if (digitalRead(2)) {
    //sleepNow();
    f_sleepButton++;
    clearsleepTimer();
    delay(50);
  }
  if (f_sleepButton == 24) {  // 长按1.2秒关机
    sleepNow();
  }
  if (f_sleepTimer == 10) { // 延时没有操作关机
    sleepNow();
  }
}

void sleepTimer() {
  f_sleepTimer++;
}

void sleepNow()         // here we put the arduino to sleep
{
  //detachInterrupt(0);
  digitalWrite(pin, HIGH);

  //delay(1000);
  //return;
  //Serial.print("sleep_enable\n");


  /* Now is the time to set the sleep mode. In the Atmega8 datasheet
     http://www.atmel.com/dyn/resources/prod_documents/doc2486.pdf on page 35
     there is a list of sleep modes which explains which clocks and
     wake up sources are available in which sleep modus.

     In the avr/sleep.h file, the call names of these sleep modus are to be found:

     The 5 different modes are:
         SLEEP_MODE_IDLE         -the least power savings
         SLEEP_MODE_ADC
         SLEEP_MODE_PWR_SAVE
         SLEEP_MODE_STANDBY
         SLEEP_MODE_PWR_DOWN     -the most power savings

     For now, we want as much power savings as possible,
     so we choose the according sleep modus: SLEEP_MODE_PWR_DOWN

  */
  set_sleep_mode(SLEEP_MODE_PWR_DOWN);   // sleep mode is set here

  sleep_enable();              // enables the sleep bit in the mcucr register
  // so sleep is possible. just a safety pin

  /* Now is time to enable a interrupt. we do it here so an
     accidentally pushed interrupt button doesn't interrupt
     our running program. if you want to be able to run
     interrupt code besides the sleep function, place it in
     setup() for example.

     In the function call attachInterrupt(A, B, C)
     A   can be either 0 or 1 for interrupts on pin 2 or 3.

     B   Name of a function you want to execute at interrupt for A.

     C   Trigger mode of the interrupt pin. can be:
                 LOW        a low level triggers
                 CHANGE     a change in level triggers
                 RISING     a rising edge of a level triggers
                 FALLING    a falling edge of a level triggers

     In all but the IDLE sleep modes only LOW can be used.
  */

  attachInterrupt(0, wakeUpNow, RISING ); // use interrupt 0 (pin 2) and run function
  // wakeUpNow when pin 2 gets LOW

  sleep_mode();                // here the device is actually put to sleep!!
  //

  sleep_disable();             // first thing after waking from sleep:
  // disable sleep...


  detachInterrupt(0);          // disables interrupt 0 on pin 2 so the
  // wakeUpNow code will not be executed
  // during normal running time.
  power_all_enable();/* Re-enable the peripherals. */

  delay(100);                 // wat 2 sec. so humans can notice the
  // interrupt.
  // LED to show the interrupt is handled
  digitalWrite (pin, LOW);      // turn off the interrupt LED

}

void wakeUpNow()
{ //Serial.print("wakeUpNow\n");
  f_sleepButton = 0;
  //digitalWrite(pin, LOW);
  //attachInterrupt(0,sleepNow, FALLING ); // 睡眠模式
}

void clearsleepTimer() {
  f_sleepTimer = 0;
}

 

Copyright 版权声明写法

正确的格式应该是:Copyright [dates] by [author/owner] 

© 通常可以代替Copyright, 但是不可以用(c)。 All Rights Reserved 在某些国家曾经是必须的,但是现在在大多数国家,都不是法律上必须有的字样。 

参见下面几个正确的格式: 

©1995-2004 Macromedia, Inc. All rights reserved. 

©2004 Microsoft Corporation. All rights reserved. 

Copyright © 2004 Adobe Systems Incorporated. All rights reserved. 

©1995-2004 Eric A. and Kathryn S. Meyer. All Rights Reserved. 

请注意标点符号和大小写的用法,这也是专业精神的一种体现。 

现在流行some rights reserved:creativecommons.org 

some rights reserved 和copyright 本身并不矛盾,但是其中的界限更多是一个道德问题,真正的保留一部分权力,是指给浏览者fair use 的权利,fair use的界定也决不是随便乱用,或者抄袭。 

甚至说,除了copyright, 还有copyleft,它的定义是为了程序员开发能够共享源代码的一个方式,英文里free, 并不仅仅是免费。 而且这种的源码公开免费使用,和版权也一点都不冲突。请大家不要误解。
 

mac下github多账户设置

从github上新clone一个项目,修改后,push新代码,报错如下: 
ERROR: Permission to xxx.git denied to sb. 
fatal: Could not read from remote repository. 
Please make sure you have the correct access rights 
经过多方询查,原因大概就是之前电脑上有一个账号已经绑定了他的github账号,默认就是他的账号在连接新的项目,而又没有给此账号开通权限,导致push不上去,大致方法是清楚原账号的相关信息,比如删除或者编辑github的钥匙串,或者在终端执行如下代码等: 
最后,在阅读了https://blog.csdn.net/zqy0zqy/article/details/78657458http://blog.csdn.net/ltstud/article/details/77895382?locationNum=10&fps=1 博主的文章后,终于解决了这个难题(十分感谢),步骤如下(即重新生成一个做绑定): 
1,在.ssh文件夹下新建文件github(以防万一,可先备份原.ssh文件夹,虽然没啥必要) 

2,ssh-keygen -t rsa -C “github_publicKey_a” 
不回车,设置新的文件名,以和原来的区分开,如 id_rsa_a
然后回车,回车,回车,即在github下生成新的公钥 

接着再如法炮制生成id_rsa_b


3,把公钥分别添加到github账号上(头像-Settings-SSH and GPG keys-New SSH key) 

4,打开/Users/(username)/.ssh/config文件,如果没有就创建(nano  比较好用),并写入新的host相关配置:如 

Host github-a(账号a别名) 
HostName github.com 
User git 
IdentityFile /Users/(username)/.ssh/github/id_rsa_a 

Host github-b(账号b别名) 
HostName github.com 
User git 
IdentityFile /Users/(username)/.ssh/github/id_rsa_b
5,回到项目目录,git remote -v 查看现在连接的是否是正确的github库 
6,修改host名: 
git remote set-url origin github-a:xxx/yyy.git 
(ssh -T github-a 查看是否修改成功 会显示如下信息: 
Hi username! You’ve successfully authenticated。。。。。。) 
git remote -v 查看连接,已经变成了新的host别名 
7,重新push之前的代码,成功!
--------------------- 
原作者:xzz_wcc 
来源:CSDN 
原文:https://blog.csdn.net/zqy0zqy/article/details/78657458 

口吐白沫的水煮蛋

早期给娃做饭,常规餐是白粥+水煮蛋。

常常被吐槽蛋煮的口吐白沫

痛定思痛,冰箱里冬眠的蛋,被煮蛋器极速加热,起床气发作(:雾,受热不均匀),炸裂了devil

于是,想到了一个洗蛋时不合常理的方法,

煮蛋前用热水洗蛋(划重点),让整个蛋都

再放进煮蛋器,甚至可以直接用热水开始煮,请看成品

。。

。。。

。。。。

早餐愉快!