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 HAL_AFE_Init1MHZ_Clock(void){ | |
//RCC_AHB1PeriphClockCmd(HAL_DS_AFE_CLK1MHZ_PORT_GPIO_AHB_BIT, ENABLE); | |
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE); | |
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE); | |
GPIO_Init(HAL_DS_AFE_CLK1MHZ_PORT, (GPIO_InitTypeDef *) &HAL_DS_1MHz_CLK_GpioConfiguration); | |
GPIO_PinAFConfig(HAL_DS_AFE_CLK1MHZ_PORT, HAL_DS_AFE_CLK1MHZ_AF_PINSOURCE ,GPIO_AF_TIM2); | |
TIM_TimeBaseInitTypeDef TIM2_TimeBaseStructure; | |
TIM2_TimeBaseStructure.TIM_Period = 21; |
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
{% with object.group_set.all|first as group %} | |
<li class="breadcrumb-item"><a href="{% url 'group_detail' group_id=view.kwargs.group_id %}">{{ group.name }}</a></li> | |
{% endwith %} |
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 SimpleProjectModelChoicesField(ModelChoiceField): | |
def label_from_instance(self, obj): | |
return '{name}'.format(name=obj.name) | |
class CourseForm(ModelForm): | |
project = SimpleProjectModelChoicesField(queryset=Project.objects.filter(is_active=True)) | |
def __init__(self, *args, **kwargs): | |
self.request = kwargs.pop("request") |
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
_getLeftActivationDays = (finishDate) => { | |
var endDate = new Date(finishDate); | |
var today = new Date(); | |
var oneDay = 24 * 60 * 60 * 1000; | |
return Math.round(Math.abs((today.getTime() - endDate.getTime())/ oneDay)); | |
} |
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
#!/bin/bash | |
DEVICE=/dev/ttyUSB0 | |
BAUDRATE=230400 | |
echo "=======SETTINGS=========" | |
echo "port: $DEVICE" | |
echo "spped: $BAUDRATE" | |
echo "========================" |
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
import serial | |
import time | |
def main(): | |
ser = serial.Serial('/dev/ttyUSB0', 230400, timeout=1) | |
print(ser.name) | |
count = 0 | |
while 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
GPIO_InitTypeDef GPIO_I2CInitStructure; | |
/*Workaround p26 errata STM32F103*/ | |
__HAL_I2C_DISABLE(&hi2c1); | |
//OD HIGHG | |
GPIO_I2CInitStructure.Pin = I2C_SCL_PIN | I2C_SDA_PIN; | |
GPIO_I2CInitStructure.Mode = GPIO_MODE_OUTPUT_OD; | |
GPIO_I2CInitStructure.Pull = GPIO_PULLUP; | |
HAL_GPIO_Init(I2C_PORT, &GPIO_I2CInitStructure); | |
HAL_GPIO_WritePin(I2C_PORT, I2C_SCL_PIN, GPIO_PIN_SET); | |
HAL_GPIO_WritePin(I2C_PORT, I2C_SDA_PIN, GPIO_PIN_SET); |
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
*ptr = '\n'; | |
ptr++; | |
*ptr = '\n'; | |
ptr++; | |
base = (PacketHdrBase*)ptr; |
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
//Done in a MapFragment | |
@Override | |
public void onMapReady(GoogleMap googleMap) { | |
mMap = googleMap; | |
UiSettings mapUiSettings = mMap.getUiSettings(); | |
mapUiSettings.setCompassEnabled(false); | |
mapUiSettings.setZoomControlsEnabled(false); | |
mapUiSettings.setMapToolbarEnabled(false); | |
} |
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
@Test | |
public void testGzipSource() throws IOException { | |
String original = "Some super super long string.Some super super long string." + | |
"Some super super long string." + | |
"Some super super long string." + | |
"Some super super long string." + | |
"Some super super long string." + | |
"Some super super long string." + | |
"Some super super long string." + | |
"Some super super long string."; |
NewerOlder