自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(25)
  • 资源 (4)
  • 收藏
  • 关注

原创 Brightbox App Tech Support

Brightbox screen shotGetting Support:mail: luobaotai@gmail.comor leave comment below.

2024-03-06 14:13:41 346

原创 Linux中的list_entry和container_of(转载)

转自http://hi.baidu.com/mynana/blog/item/1da1ba99239ceb006f068c48.htmllist_entry宏是用来根据list_head指针查找链表所嵌入的结构体的地址,具体实现是依赖宏container_of:#define list_entry(ptr, type, member)container_of(ptr, type, member)container_of的定义如下: 1 /** 2 * container_of ..

2021-01-09 13:50:04 273

原创 c++学习笔记:lvalues, rvalues, 左值引用, 右值引用(c++11起)

int a = 12;int b = a+1;int foo(){ return 2;}a--左值12--右值a+1--右值foo()--右值int foo(){ return 2;}foo() = 2;//错误。foo()是右值int& foo1(){ int a = 3 return a;}foo1() = 2;//正确,foo1()是左值int& a = 2;//错误,a为左值引用,不能赋右值co.

2020-12-24 11:15:07 128

原创 c++学习笔记:单例最优实现

#include <iostream>class Singleton {public: ~Singleton() { std::cout << "destructor called!" << std::endl; } Singleton(const Singleton&) = delete; Singleton& operator = (const Singleton&) = delete; static Singleton&.

2020-12-21 14:09:59 125

原创 c++学习笔记:variant实现多类型变量,替代optional

c++17可用variant,实现多类型变量。比起optional,自由度更高。如下代码判断一个数字是否大于5,如果大于5,输出bignumber,否则输出enum值#include <iostream>#include <variant>#include <string>enum class ErrorCode { BIGNUMBER = 0, SMALLNUMBER=1, ERROR=2};std::variant<std::string,

2020-12-19 10:18:20 417 1

原创 stm32学习笔记:SysTick定时器,delay_ms

参考链接:https://yngzmiao.blog.csdn.net/article/details/79843806#include "stm32f10x.h"u16 fac_us, fac_ms;void delay_init(){ SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK_Div8); //选择外部时钟 HCLK/8 fac_us=SystemCoreClock/8000000; //为系统时钟的1/8,实际上也.

2020-12-16 14:11:00 2349

原创 c++学习笔记:dynamic_cast

对于父类Entity,有两个子类:Player,Enemy。如果定义一个 Entity* 类型变量,如下Entity* actuallyEnemy = new Enemy();即用Enemy类的构造函数为变量赋值,默认会发生子类向父类的类型转换,不会有问题如果此时将该变量赋给Player类型的指针,就会出问题Player* player = actuallyEnemy;为了避免这种错误的类型转换,需要用到dynamic_castPlayer* p0 = dynamic_cast

2020-12-16 10:13:48 138

原创 c++学习笔记:virtual constructor

使用子类创建对象,并给父类指针赋值时,当调用delete语句时,只会调用父类的析构函数。这样,如果在子类的析构函数中有数据操作,就可能发生内存泄漏。#include <iostream>class Base {public: Base() { std::cout << "Base Constructor\n"; } ~Base() { std::cout << "Base Destructor\n"; }};class Derived :

2020-12-14 11:33:08 372

原创 c++笔记6:union的一种用法

如果有些场景中需要用多种方式调用同一个值,可以用union定义二维向量结构:struct Vector2 { int a, b;}定义四维向量结构:struct Vector4 { union { struct { int x, y, z, w; }; struct { Vector2 m, n; }; };};四维向量包含四个数据。除了x,y,z,w一种定义外,还可以利用二维向量。这样四维向量便有了两种使用方式#include <

2020-12-14 09:16:17 201

原创 c++笔记5:使用指针操作内存

#include <iostream>struct Entity { int x, y;};int main() { Entity e = {5, 8}; int x = *(int*)&e; std::cout << x << std::endl; std::cin.get();}输出:5#include <iostream>struct Entity { int x, y;};int main().

2020-12-13 09:41:40 146

原创 STM32学习笔记:USART

参考https://blog.csdn.net/zcy_cyril/article/details/105977121#include "stm32f10x.h"//配置NVICvoid NVIC_Config(void){ NVIC_InitTypeDef NVIC_InitStructure; NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn.

2020-12-11 14:32:15 126

原创 stm32学习笔记:中断

实现功能:PA0上升沿中断,PC13led闪烁主程序#include "stm32f10x.h" GPIO_InitTypeDef GPIO_InitStruct;//嵌入式向量中断控制器配置函数void NVIC_Config(){ NVIC_InitTypeDef NVIC_InitStruct;//NVIC配置结构体 //配置抢占优先级和子优先级的位数分配,NVIC_PriorityGroup_1表示抢占优先级占1位,子优先级占3位 NVIC_PriorityGroupCon

2020-12-10 15:30:50 155

原创 c++学习笔记4:chrono 计时

要获取代码运行的时间,一个比较好的方式是使用chrono。看例子,在两次获取时间的代码中间,休眠1s#include <iostream>#include <chrono>#include <thread>int main() { using namespace std::literals::chrono_literals; auto start = std::chrono::high_resolution_clock::now(); std:

2020-12-10 09:42:35 787

原创 c++学习笔记3:thread

几个概念:join,detach,mutex使用join,则join之前的各个线程并发执行,但是join之后的主线程代码会等待用户开启的线程执行完后才执行使用detach,则新开线程与主线程并发执行,互不影响如果多个线程要操作同一个数据时,要使用互斥锁mutex,保证数据同步#include <iostream>#include <thread>#include <mutex>std::mutex mt;int data = 1;void.

2020-12-09 14:33:14 51

原创 c++学习笔记2:函数指针及lambda使用

void(*func)(int)----指的是一个函数指针类型变量,变量名为func,该变量指向一种函数类型,该函数有一个int类型参数,返回值为void#include <iostream>#include <vector>void PrintValue(int value) { std::cout << value << std::endl;}void forEach(const std::vector<int>&

2020-12-07 08:52:31 527

原创 STM32F10x笔记1:GPIO操作(基于标准库,使用keil)

第一种方式,配置寄存器#include "stm32f10x.h"GPIO_InitTypeDef GPIO_InitStructure;void delay(){ int i = 500000; while(i--);}int main(void){ /*!< At this stage the microcontroller clock setting is already configured, this is done through Syste.

2020-12-03 15:34:02 1119

原创 C++笔记1:template (1)函数入参多元化,可变长数组

1. 使用template实现函数入参多元化:#include <iostream>#include <string>template<typename T>void Print(T value) { std::cout << value << std::endl;}int main() { Print(5); Print("luobaotai"); Print(5.5f); std::cin.get();}

2020-12-03 09:27:59 254

原创 Android 笔记1: Activity之间传递数据,Bundle,Parcelable

Activity之间使用Bundle对象传递数据,一般常用类型的数据已经集成到Bundle中,但是一些自定义的data类没有。这时候,需要用到Parcelable来让自定义类支持Bundle机制。一个类要实现Parcelable很简单,基本借助于IDE可以自动生成。在目标Activity中接收数据时,使用如下操作:var luo = this.intent.getParcelableExtra<Luo>("luo")this为Activity上下文,直接获取Intent对象,通

2020-12-02 20:21:45 271

原创 c++ vector容器 创建动态数组及拷贝优化

vector包含在c++标准模版库中,能够存放任意类型的动态数组,类似于一个容器,能够增加数据和减少数据使用方法如下:#include <iostream>#include <vector>struct Vertex{ int x,y,z; Vertex(int a, int b, int c) : x(a), y(b),z(c){}};std::ostream& operator<<(std::ostream& stream

2020-11-23 11:34:19 857

原创 c++智能指针对象直接调用封装类的成员方法

为了对分配到heap的对象进行生命周期控制(new方法创建的对象,假设为类Entity),需要用到智能指针类(假设为ScopePtr)。该类封装了一个指针,指针指向类型为要控制的类。#include <iostream>class Entity{public: int x;public: void Print() const { std::cout << "Hello" <<std::endl; }};class ScopePtr{pri

2020-11-22 20:28:07 521

原创 C++ deep copy 深度拷贝

当类的成员变量存在指针类型时,如果采用赋值语句将一个该类对象赋给另外一个对象时,默认会采用浅拷贝,也即两个指针类型的成员变量指向同一个地址,这样当对象生命周期结束时会调用析构函数,释放相应的内存地址。但是由于浅拷贝,会导致释放发生两次,如此第二次释放发生时,因为已经被释放过一次,所以程序会奔溃。代码如下:#include <iostream>#include <string>class String{private: char* m_Buffer; unsigne

2020-11-22 10:59:30 3206 1

转载 详解C++11智能指针(转载)

https://www.cnblogs.com/WindSun/p/11444429.html原文链接前言C++里面的四个智能指针: auto_ptr, unique_ptr,shared_ptr, weak_ptr 其中后三个是C++11支持,并且第一个已经被C++11弃用。C++11智能指针介绍智能指针主要用于管理在堆上分配的内存,它将普通的指针封装为一个栈对象。当栈对象的生存周期结束后,会在析构函数中释放掉申请的内存,从而防止内存泄漏。C++ 11中最常用的智能指针类型为sha..

2020-11-20 09:28:47 107

原创 c/c++ 命令行编译多个源文件

c:gcc -o filename.out file1.c file2.c file3.c -o --- 指定可执行文件名,否则默认a.out filename.out --- 生成的可执行文件 file1.c --- 源文件c++:使用g++指令,其余相同,注意为.cpp

2020-11-13 09:15:07 350

原创 mac 安装 homebrew 即brew

使用国内镜像源/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"出现绿色提示,选择一个镜像源,此处选的中科大然后可以了

2020-11-05 17:45:43 73

原创 ESP8266擦除flash for mac

#pip install esptool# pip install pyserialcd到python2.7目录,一般在/Library/Python/2.7/bin,确认是否有esptool.py的bin文件执行esptool.py--port COM4 erase_flash 将com4替换为 /dev/*****,即mac对应的串口名称

2020-11-04 15:27:39 276

谷歌人工智能框架

谷歌开源人工智能框架,tensorflow,有兴趣的朋友可以下载看看

2016-04-12

SmallRTOS微型操作系统

SmallRTOS微型操作系统,帮助您了解系统源码的好工具

2015-11-14

Learning ROS for Robotics Programming.zip

( Learning ROS for Robotics Programming.zip )一书的源代码。想熟悉ROS系统,不可错过

2015-11-09

android4.0源代码

安卓4.0源代码,学习安卓系统的必须选择。本人已经实际使用多次,请放心下载。欢迎更多分享

2015-10-17

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除