This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"flag" | |
"os" | |
"bufio" | |
"strings" | |
"golang.org/x/text/encoding/charmap" | |
"strconv" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "lcd_5110_imp.h" | |
static void init_display(); | |
static void write_to_display(uint8_t data, uint8_t mode); | |
static void clear_lcd(); | |
static void lcd_cs(uint8_t state); | |
static void lcd_rst(uint8_t state); | |
static void lcd_dc(uint8_t state); | |
static void lcd_din(uint8_t state); | |
static void lcd_sck(uint8_t state); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void lcd_implementation_init() { | |
GPIO_InitTypeDef ports; | |
RCC_AHB1PeriphClockCmd(RCC_GPIO, ENABLE); | |
//Declare pins to configure | |
ports.GPIO_Pin = CS_PIN | RST_PIN | DC_PIN | DIN_PIN | SCK_PIN | LED_PIN; | |
ports.GPIO_Speed = GPIO_Speed_100MHz; | |
ports.GPIO_Mode = GPIO_Mode_OUT; | |
ports.GPIO_OType = GPIO_OType_PP; | |
//Init Port | |
GPIO_Init(GPIO_PORT, &ports); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DMA_DeInit(DMA1_Stream5); | |
DMA_INIT.DMA_Channel = DMA_Channel_7; | |
DMA_INIT.DMA_PeripheralBaseAddr = (uint32_t)&DAC->DHR12L1;//->DHR12R1;// &DAC->DHR12L1; DHR8R1; | |
DMA_INIT.DMA_Memory0BaseAddr = (uint32_t)&dac_buff; | |
DMA_INIT.DMA_DIR = DMA_DIR_MemoryToPeripheral; | |
DMA_INIT.DMA_BufferSize = 512; | |
DMA_INIT.DMA_PeripheralInc = DMA_PeripheralInc_Disable; | |
DMA_INIT.DMA_MemoryInc = DMA_MemoryInc_Enable; | |
DMA_INIT.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord; | |
DMA_INIT.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void btn_init_port_pins(GPIO_TypeDef* GPIOx, uint32_t RCClocking, uint32_t pins) { | |
GPIO_InitTypeDef GPIO_InitStructure; | |
RCC_AHB1PeriphClockCmd(RCClocking, ENABLE); | |
GPIO_InitStructure.GPIO_Pin = pins; | |
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; | |
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; | |
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; | |
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; | |
GPIO_Init(GPIOx, &GPIO_InitStructure); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void btn_loop(void) { | |
uint16_t port0 = GPIO_ReadInputData(BTN_PORT_0); | |
uint16_t port1 = GPIO_ReadInputData(BTN_PORT_1); | |
if(port0 & (BTN_PORT_0_PINS)) { | |
if(port0 & BTN_PORT_0_PIN_0) btn_callback_clicked_0_0() | |
else if(port0 & BTN_PORT_0_PIN_1) btn_callback_clicked_0_1() | |
else if(port0 & BTN_PORT_0_PIN_2) btn_callback_clicked_0_2() | |
else if(port0 & BTN_PORT_0_PIN_3) btn_callback_clicked_0_3(); | |
} else if(port1 & (BTN_PORT_1_PINS)) { | |
if(port1 & BTN_PORT_1_PIN_0) btn_callback_clicked_1_0() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var f1 = function() { return 1} | |
undefined | |
var arr = [f1]; | |
undefined | |
arr; | |
[f1()] | |
arr.filter(function(r) { r != f1 }); | |
[] | |
arr; | |
[f1()] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User(Base): | |
__tablename__ = 'users' | |
id = Column(Integer, primary_key=True) | |
name = Column(String(32), unique=True, nullable=False) | |
email = Column(String(64), unique=True, nullable=False) | |
password = Column(String(64), nullable=False) | |
class Device(Base): | |
__tablename__ = 'devices' | |
id = Column(Integer, primary_key=True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def user_register(session, username, password, email): | |
try: | |
new_user = User(name=username, email=email) | |
session.add(new_user) | |
session.commit() | |
return True, 'ok' | |
except exc.IntegrityError as e: | |
session.rollback() | |
code, msg = e.orig | |
print msg |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1> F = fun(N) -> list_to_atom(integer_to_list(N)), timer:sleep(infinity) end. | |
17> [spawn(fun() -> F(N) end) || N <- lists:seq(1, 100000)]. | |
[<0.751.0>,<0.752.0>,<0.753.0>,<0.754.0>,<0.755.0>, | |
<0.756.0>,<0.757.0>,<0.758.0>,<0.759.0>,<0.760.0>,<0.761.0>, | |
<0.762.0>,<0.763.0>,<0.764.0>,<0.765.0>,<0.766.0>,<0.767.0>, | |
<0.768.0>,<0.769.0>,<0.770.0>,<0.771.0>,<0.772.0>,<0.773.0>, | |
<0.774.0>,<0.775.0>,<0.776.0>,<0.777.0>,<0.778.0>,<0.779.0>|...] | |
18> erlang:memory(atom_used). | |
2255590 | |
19> erlang:memory(atom). |